Appendix 1: Education Variable Creation

Return to Table of Contents


Enrollment Status, Highest Grade Completed, and Highest Degree Received

Variables Created:

Variables Used

Name in Program Question Name in Data   Name in Program Question Name in Data   Name in Program Question Name in Data

Round 1 data:

 

 

Round 8 data:

 

 

Round 9 raw data con't:

 

e3500r1

YSCH-3500

 

e2857r8

YSCH-2857

 

e9691mr9_212

YSCH-9691.02.01.02~M

e5000r1

YSCH-5000

 

e3112r8

YSCH-3112

 

e9691yr9_212

YSCH-9691.02.01.02~Y

t7000r1_1-_3

YTRN-7000.01-.03

 

e3878r8

YSCH-3878

 

e9691mr9_213

YSCH-9691.02.01.03~M

encatr1

CV_ENROLLSTAT

 

t7000r8_1-_7

YTRN-7000.01-.07

 

e9691yr9_213

YSCH-9691.02.01.03~Y

GRSURVr1

CV_HGC_EVER

 

encatr8

CV_ENROLLSTAT

 

e9691mr9_311

YSCH-9691.03.01.01~M

DEGSURVr1

CV_HIGHEST_DEGREE_EVER

 

grsurvr8

CV_HGC_EVER

 

e9691yr9_311

YSCH-9691.03.01.01~Y

gdr1

CV_GED

 

grjuner8

CV_HGC_YR

 

e9691mr9_312

YSCH-9691.03.01.02~M

hsr1

CV_HS_DIPLOMA

 

degsurvr8

CV_HIGHEST_DEGREE_EVER

 

e9691yr9_312

YSCH-9691.03.01.02~Y

doicmr1

CV_INTERVIEW_CMONTH

 

degjuner8

CV_HIGHEST_DEGREE_YR

 

e9691mr9_313

YSCH-9691.03.01.03~M

 

 

 

gdr8

CV_GED

 

e9691yr9_313

YSCH-9691.03.01.03~Y

Round 2 data:

 

 

hsr8

CV_HS_DIPLOMA

 

e9946r9_111-_113

YSCH-9946.01.01.01-.03

e2857r2

YSCH-2857

 

aar8

CV_AA_DEGREE

 

e9946r9_211-_213

YSCH-9946.02.01.01-.03

e3112r2

YSCH-3112

 

bar8

CV_BA_DEGREE

 

e9946r9_311-_313

YSCH-9946.03.01.01-.03

e3878r2

YSCH-3878

 

doicmr8

CV_INTERVIEW_CMONTH

 

e10099mr9_111

YSCH-10099.01.01.01~M

t7000r2_1, _2

YTRN-7000.01, .03

 

comp_mo_LR

From r8 program

 

e10099yr9_111

YSCH-10099.01.01.01~Y

encatr2

CV_ENROLLSTAT

 

comp_yr_LR

From r8 program

 

e10099mr9_112

YSCH-10099.01.01.02~M

grsurvr2

CV_HGC_EVER

 

 

 

 

e10099yr9_112

YSCH-10099.01.01.02~Y

grjuner2

CV_HGC_YR

 

Round 9 raw data:

 

 

e10099mr9_113

YSCH-10099.01.01.03~M

degsurvr2

CV_HIGHEST_DEGREE_EVER

 

e3103r9

YSCH-3103

 

e10099yr9_113

YSCH-10099.01.01.03~Y

degjuner2

CV_HIGHEST_DEGREE_YR

 

e3104r9

YSCH-3104

 

e10099mr9_211

YSCH-10099.02.01.01~M

hsr2

CV_HS_DIPLOMA

 

e2806r9

YSCH-2806

 

e10099yr9_211

YSCH-10099.02.01.01~Y

gdr2

CV_GED

 

e2857r9

YSCH-2857

 

e10099mr9_212

YSCH-10099.02.01.02~M

doicmr2

CV_INTERVIEW_CMONTH

 

e3010r9

YSCH-3010

 

e10099yr9_212

YSCH-10099.02.01.02~Y

 

 

 

e3061r9

YSCH-3061

 

e10099mr9_213

YSCH-10099.02.01.03~M

Round 3 data:

 

 

e3112r9

YSCH-3112

 

e10099yr9_213

YSCH-10099.02.01.03~Y

e2857r3

YSCH-2857

 

e3877r9

YSCH-3877

 

e10099mr9_311

YSCH-10099.03.01.01~M

e3112r3

YSCH-3112

 

e3877br9

YSCH-3877B

 

e10099yr9_311

YSCH-10099.03.01.01~Y

e3878r3

YSCH-3878

 

e3878r9

YSCH-3878

 

e10099mr9_312

YSCH-10099.03.01.02~M

t7000r3_1-_4

YTRN-7000.01-.04

 

e4785mr9

YSCH-4785~M

 

e10099yr9_312

YSCH-10099.03.01.02~Y

encatr3

CV_ENROLLSTAT

 

e4785yr9

YSCH-4785~Y

 

e10099mr9_313

YSCH-10099.03.01.03~M

grsurvr3

CV_HGC_EVER

 

e4793r9

YSCH-4793

 

e10099yr9_313

YSCH-10099.03.01.03~Y

grjuner3

CV_HGC_YR

 

e4795r9

YSCH-4795

 

e24889mr9

YSCH-24889~M

degsurvr3

CV_HIGHEST_DEGREE_EVER

 

e4846mr9

YSCH-4846~M

 

e24889yr9

YSCH-24889~Y

degjuner3

CV_HIGHEST_DEGREE_YR

 

e4846yr9

YSCH-4846~Y

 

e24940mr9

YSCH-24940~M

gdr3

CV_GED

 

e1600r9

YSCH-1600

 

e24940yr9

YSCH-24940~Y

hsr3

CV_HS_DIPLOMA

 

e1605r9

YSCH-1605

 

e27337r9_1-_4

YSCH-27337.01-.04

aar3

CV_AA_DEGREE

 

e1610mr9_1

YSCH-1610.01~M

 

e23450r9_1-_3

YSCH-23450.01-.03

bar3

CV_BA_DEGREE

 

e1610yr9_1

YSCH-1610.01~Y

 

t7000r9_1-_9

YTRN-7000.01-.09

doicmr3

CV_INTERVIEW_CMONTH

 

e1610mr9_2

YSCH-1610.02~M

 

PUBID

PUBID

 

 

 

e1610yr9_2

YSCH-1610.02~Y

 

intdr9

SYMBOL_CURDATE~D

Round 4 data:

 

 

e1615r9_1, _2

YSCH-1615.01, .02

 

intmr9

SYMBOL_CURDATE~M

e2857r4

YSCH-2857

 

e1620mr9_1

YSCH-1620.01~M

 

intyr9

SYMBOL_CURDATE~Y

e3112r4

YSCH-3112

 

e1620yr9_1

YSCH-1620.01~Y

 

PREVGRADE_IN_r9

SYMBOL_PREV_GRADE_IN

e3878r4

YSCH-3878

 

e1624r9_1

YSCH-1624.01

 

 

 

t7000r4_1-_4

YTRN-7000.01-.04

 

e1625r9_1

YSCH-1625.01

 

Round 9 roster data:

 

encatr4

CV_ENROLLSTAT

 

e1627r9_1

YSCH-1627.01

 

lftscr9_1-_4

NEWSCHOOL_LEFT.01-.04

grsurvr4

CV_HGC_EVER

 

e4951r9

YSCH-4951

 

scoder9_1-_4

NEWSCHOOL_SCHCODE.01-.04

grjuner4

CV_HGC_YR

 

e5458r9_1-_3

YSCH-5458.01-.03

 

strtmr9_11

NEWSCHOOL_START1.01~M

degsurvr4

CV_HIGHEST_DEGREE_EVER

 

e6682mr9_1

YSCH-6682.01~M

 

strtyr9_11

NEWSCHOOL_START1.01~Y

degjuner4

CV_HIGHEST_DEGREE_YR

 

e6682yr9_1

YSCH-6682.01~Y

 

strtmr9_12

NEWSCHOOL_START1.02~M

gdr4

CV_GED

 

e6682mr9_2

YSCH-6682.02~M

 

strtyr9_12

NEWSCHOOL_START1.02~Y

hsr4

CV_HS_DIPLOMA

 

e6682yr9_2

YSCH-6682.02~Y

 

strtmr9_13

NEWSCHOOL_START1.03~M

aar4

CV_AA_DEGREE

 

e6682mr9_3

YSCH-6682.03~M

 

strtyr9_13

NEWSCHOOL_START1.03~Y

bar4

CV_BA_DEGREE

 

e6682yr9_3

YSCH-6682.03~Y

 

strtmr9_14

NEWSCHOOL_START1.04~M

doicmr4

CV_INTERVIEW_CMONTH

 

e6784r9_1-_3

YSCH-6784.01-.03

 

strtyr9_14

NEWSCHOOL_START1.04~Y

 

 

 

e6835mr9_1

YSCH-6835.01~M

 

stopmr9_11

NEWSCHOOL_STOP1.01~M

Round 5 data:

 

 

e6835yr9_1

YSCH-6835.01~Y

 

stopyr9_11

NEWSCHOOL_STOP1.01~Y

e2857r5

YSCH-2857

 

e6835mr9_2

YSCH-6835.02~M

 

stopmr9_12

NEWSCHOOL_STOP1.02~M

e3112r5

YSCH-3112

 

e6835yr9_2

YSCH-6835.02~Y

 

stopyr9_12

NEWSCHOOL_STOP1.02~Y

e3878r5

YSCH-3878

 

e6835mr9_3

YSCH-6835.03~M

 

stopmr9_13

NEWSCHOOL_STOP1.03~M

t7000r5_1-_4

YTRN-7000.01-.04

 

e6835yr9_3

YSCH-6835.03~Y

 

stopyr9_13

NEWSCHOOL_STOP1.03~Y

encatr5

CV_ENROLLSTAT

 

e6889r9_1-_3

YSCH-6889.01-.03

 

stopmr9_14

NEWSCHOOL_STOP1.04~M

grsurvr5

CV_HGC_EVER

 

e6937r9_1-_3

YSCH-6937.01-.03

 

stopyr9_14

NEWSCHOOL_STOP1.04~Y

grjuner5

CV_HGC_YR

 

e6938r9_1-_3

YSCH-6938.01-.03

 

strtmr9_21

NEWSCHOOL_START2.01~M

degsurvr5

CV_HIGHEST_DEGREE_EVER

 

e6941mr9_11

YSCH-6941.01.01~M

 

strtyr9_21

NEWSCHOOL_START2.01~Y

degjuner5

CV_HIGHEST_DEGREE_YR

 

e6941yr9_11

YSCH-6941.01.01~Y

 

strtmr9_23

NEWSCHOOL_START2.03~M

gdr5

CV_GED

 

e6941mr9_21

YSCH-6941.02.01~M

 

strtyr9_23

NEWSCHOOL_START2.03~Y

hsr5

CV_HS_DIPLOMA

 

e6941yr9_21

YSCH-6941.02.01~Y

 

stopmr9_21

NEWSCHOOL_STOP2.01~M

aar5

CV_AA_DEGREE

 

e6943r9_11

YSCH-6943.01.01

 

stopyr9_21

NEWSCHOOL_STOP2.01~Y

bar5

CV_BA_DEGREE

 

e6943r9_21

YSCH-6943.02.01

 

strtmr9_31

NEWSCHOOL_START3.01~M

doicmr5

CV_INTERVIEW_CMONTH

 

e6944mr9_11

YSCH-6944.01.01~M

 

strtyr9_31

NEWSCHOOL_START3.01~Y

 

 

 

e6944yr9_11

YSCH-6944.01.01~Y

 

stopmr9_31

NEWSCHOOL_STOP3.01~M

Round 6 data:

 

 

e6947r9_11

YSCH-6947.01.01

 

stopyr9_31

NEWSCHOOL_STOP3.01~Y

e2857r6

YSCH-2857

 

e7142r9_11

YSCH-7142.01.01

 

 

 

e3112r6

YSCH-3112

 

e7142r9_21

YSCH-7142.02.01

 

Round 9 created variables:

 

e3878r6

YSCH-3878

 

e7192r9_1-_3

YSCH-7192.01-.03

 

CDTGD

CV_GED

t7000r6_1-_4

YTRN-7000.01-.04

 

e8416r9_11, _12

YSCH-8416.01.01, .02

 

CDTHS

CV_HS_DIPLOMA

encatr6

CV_ENROLLSTAT

 

e8416r9_21

YSCH-8416.02.01

 

CDTAA

CV_AA_DEGREE

grsurvr6

CV_HGC_EVER

 

e8416r9_31

YSCH-8416.03.01

 

CDTBA

CV_BA_DEGREE

grjuner6

CV_HGC_YR

 

e8774mr9_11

YSCH-8774.01.01~M

 

CDTMA

CV_MA_DEGREE

degsurvr6

CV_HIGHEST_DEGREE_EVER

 

e8774yr9_11

YSCH-8774.01.01~Y

 

doicmr9

CV_INTERVIEW_CMONTH

degjuner6

CV_HIGHEST_DEGREE_YR

 

e8774mr9_12

YSCH-8774.01.02~M

 

intmr9

CV_INTERVIEW_DATE~M

gdr6

CV_GED

 

e8774yr9_12

YSCH-8774.01.02~Y

 

intyr9

CV_INTERVIEW_DATE~Y

hsr6

CV_HS_DIPLOMA

 

e9131r9_11, _12

YSCH-9131.01.01, .02

 

 

 

aar6

CV_AA_DEGREE

 

e9131r9_21

YSCH-9131.02.01

 

 

 

bar6

CV_BA_DEGREE

 

e9131r9_31

YSCH-9131.03.01

 

 

 

doicmr6

CV_INTERVIEW_CMONTH

 

e9335mr9_11

YSCH-9335.01.01~M

 

 

 

 

 

 

e9335yr9_11

YSCH-9335.01.01~Y

 

 

 

Round 7 data:

 

 

e9335mr9_21

YSCH-9335.02.01~M

 

 

 

e2857r7

YSCH-2857

 

e9335yr9_21

YSCH-9335.02.01~Y

 

 

 

e3112r7

YSCH-3112

 

e9335mr9_31

YSCH-9335.03.01~M

 

 

 

e3878r7

YSCH-3878

 

e9335yr9_31

YSCH-9335.03.01~Y

 

 

 

t7000r7_1-_4

YTRN-7000.01-.04

 

e9589r9_111-_113

YSCH-9589.01.01.01-.03

 

 

 

encatr7

CV_ENROLLSTAT

 

e9589r9_211-_213

YSCH-9589.02.01.01-.03

 

 

 

grsurvr7

CV_HGC_EVER

 

e9589r9_311-_313

YSCH-9589.03.01.01-.03

 

 

 

grjuner7

CV_HGC_YR

 

e9691mr9_111

YSCH-9691.01.01.01~M

 

 

 

degsurvr7

CV_HIGHEST_DEGREE_EVER

 

e9691yr9_111

YSCH-9691.01.01.01~Y

 

 

 

degjuner7

CV_HIGHEST_DEGREE_YR

 

e9691mr9_112

YSCH-9691.01.01.02~M

 

 

 

gdr7

CV_GED

 

e9691yr9_112

YSCH-9691.01.01.02~Y

 

 

 

hsr7

CV_HS_DIPLOMA

 

e9691mr9_113

YSCH-9691.01.01.03~M

 

 

 

aar7

CV_AA_DEGREE

 

e9691yr9_113

YSCH-9691.01.01.03~Y

 

 

 

bar7

CV_BA_DEGREE

 

e9691mr9_211

YSCH-9691.02.01.01~M

 

 

 

doicmr7

CV_INTERVIEW_CMONTH

 

e9691yr9_211

YSCH-9691.02.01.01~Y

 

 

 

Codes for Created Variables

Youth's Enrollment Status as of the Survey Date (ENCAT
1. not enrolled, no high school degree, no GED
2. not enrolled, GED, but no high school degree
3. not enrolled, a high school degree, no GED
4. not enrolled, some college
5. not enrolled, 2 year college graduate
6. not enrolled, 4 year college graduate
7. not enrolled, graduate degree
8. enrolled in grades 1-12
9. enrolled in a 2 year college
10. enrolled in a 4 year program
11. enrolled in a graduate program

 

Highest Grade Completed as of the Survey Date (GRSURV)
0.  none
1.  first
2.  second
3.  third
4.  fourth
5.  fifth
6.  sixth
7.  seventh
8.  eighth
9.  ninth
10. tenth
11. eleventh
12. twelfth
13. first year college
14. second year college
15. third year college
16. fourth year college
17. fifth year college
18. sixth year college
19. seventh year college
20. eighth year college
95. ungraded                

 

Highest Degree Received as of the Survey Date (DESURV)
0. none
1. GED
2. high school diploma
3. junior college or 2-year associate degree
4. bachelor's degree (B.A., B.S., or unspecified)
5. master's degree
6. doctoral degree
7. professional degree (M.D., L.L.D., D.D.S., J.D.)

 

Highest Grade Completed as of August 31, 2005 (GRAUG)
0.  none
1.  first
2.  second
3.  third
4.  fourth
5.  fifth
6.  sixth
7.  seventh
8.  eighth
9.  ninth
10. tenth
11. eleventh
12. twelfth
13. first year college
14. second year college
15. third year college
16. fourth year college
17. fifth year college
18. sixth year college
19. seventh year college
20. eighth year college
95. ungraded                

 

Highest Degree Completed as of August 31, 2005 (DEGAUG)
0. none
1. GED
2. high school diploma
3. junior college or 2-year associate degree
4. bachelor's degree (B.A., B.S., or unspecified)
5. doctoral degree
6. professional degree (M.D., L.L.D., D.D.S., J.D.)

This program first creates an enrollment status variable for each respondent.  It then identifies the highest grade completed by the respondent as of the round 9 interview date and as of August 31, 2005 (that is, the highest grade completed by the start of the new academic year).  Finally, it determines the highest degree or diploma received by the respondent as of the same two dates.

  1. Rs who report receiving both a GED and a H. S. Diploma are coded as receiving a H. S. Diploma
  2. Rs who report completing 12th grade but do not report receiving a H. S. Diploma or GED are coded as having completed 12th grade (in GRSURV and GRAUG, if applicable) but are not credited with a H. S. Diploma/GED on ENCAT, DEGSURV, or DEGAUG. Researchers interested in diploma receipt should use the DEGSURV or ENCAT variables, not HGC as of survey date since 12th grade completion does not necessarily signify H.S. Diploma completion.
  3. Due to conflicting reports from a small number of Rs regarding their school attendance in the loops versus in single items, invalid skips (-3) have been filled in since no reasonable determination on the enrollment and grades completed can be made (ENCAT, GRSURV, GRAUG). Specifically, Rs are assigned a -3 if they:
    a) report being not enrolled and
    b) report a HGC on the single items (e3112) that is greater than the cv_highest_degree_ever  for the prior round (but do not indicate completing this grade in a loop) and
    c) report that their HGA (e2857) is two or more greater than the HGC reported in the prior round. Since  these Rs provide inconsistent information multiple times, they have been assigned a -3.  If they provide valid information on degrees earned, that variable will have a value.
  4. Some respondents provide conflicting information of grades attended/completed in the  schooling loops (e8416 and e9589) versus the single items (e3112, e2857). These Rs were identified as below where (ENROLL=0 and 12>=e3112^=GRSURV>0 and DEGSURV not in (1,2) and GRSURV^=95) or (0<maxgrade=GRSURV<95 and GRSURV^=e3112 and e3112<=12)
    This program gives priority to information provided in the schooling loops over that provided on single item questions. Users may wish to check the CV_HGC_EVER variable against student single item self-reports of HGC (e3112), which in many cases indicates a higher grade was completed than that reported in the loops.
  5. Even if we do not have a date for the degree received (or we have an invalid date) we code the DEGSURV for that degree.
  6. If R reports being in a 4year college or university (this is one category) and pursuing a degree higher than a bachelor's we code their enrollment status as enrolled in a graduate program (ENCAT=11). The problem here is that since we are not sure whether they are in a 4-year college or a university, we are not sure whether their they are actually in a graduate program or in a bachelor's program but their ultimate academic goal is a graduate program. There are 54 cases in this category who do not have an Associates or Bachelor's degree. We could have used that criterion to identify those actually in a graduate program. The problem is that there are programs which give only a graduate degree without a bachelor's degree. So we code all these as ENCAT=11. If the questionnaire is changed to accommodate the graduate program option, these may be recoded in later rounds.

********************************************** SECTION I **********************************************;

** Initialize and define variables;

ENROLL=-3; * Indicates if R currently enrolled;

ENCAT=-3; * Enrollment status variable (including educational attainment);

HSD=0; * Indicates if R has a H. S. Diploma (check previous rounds);

GED=0; * Indicates if R has a GED (check previous rounds);

hgsch=0; * Indicates if R is currently attending grades 1-12 & no HSD or GED;

college=0; * Indicates if R is in college and working towards a undergrad (=1) or grad degree (=2);

attsch=0; * Indicates if R attended elementary, middle or high school;

flagcoll=0; * Indicates if Rs currently attending grades 1-12, no HSD or GED but enrolled in college
and working towards a grad or undergrad degree;

flaghs=0; * Indicates if Rs who have a H.S. Diploma and HGC=12 but still report enrollment in school;

somecoll=0; * Indicates if Rs have attended a college (in a degree program) in current or previous
rounds;

prevcoll=0; * Indicates if Rs have attended a college (in a degree program) in previous rounds. This
pertains to those actually enrolled in a degree program in college only;

currcoll=0; * Indicates if Rs have attended a college (in a degree program) in current round. This
pertains to those enrolled in a college and reporting to be working towards a degree
program. They may or may not be enrolled in a degree program.;

clg_ok=-4; * Indicates if R being in college (as reported in this round) w/o GED/HSD is OK. That is if
R is actually enrolled in a degree program. This pertains to currcoll and not prevcoll.;

last_enr=0; * Identifies the last round when R was enrolled;

ungraded=0; * Indicates Rs with no H.S. Diploma or GED have HGA=95 (ungraded);

same_mth=0; * Indicates Rs who received a degree in the same month as the interview.;

both=0; * Indicates that R reports receiving both GED and H. S. Diploma;

rosprb1=0; * Indicates Rs with scode(i) in (4,5) but e27337(i)=-4;

rosprb2=0; * Indicates Rs with scode(i)=-4 but e27337(i)>-4;

rosprb3=0; * Indicates cases where start and stop dates of enrollment and school codes are missing
from Roster although information is available in the data;

rosprb4=0; * Indicates cases wherer stop dates of enrollment in the Roster is not the date of current
interview although R reports being continuously enrolled in that school;

rosprb5=0; * Indicates a few special cases where the reason for leaving school were interchanged
between school loops 1 and 2;

fill=-4; * These are filler variables that are used in arrays to match the number of elements.;

chk_comm=0; * Indicates if R reports college in this round although R does not report receiving GED or
H.S. Diploma, by this round. Check the comments in current round to see whether they
were actually enrolled in a degree program in a college.;

chk_commP=0; * Indicates if ENCAT in any prior rounds shows college although R does not report
receiving GED or HS Diploma, by those rounds. Check the comments in current and earlier
rounds for these cases to see whether they were actually enrolled in a degree program in
a college.;

chk_hgc=0; * Those who received a H.S. Diploma, but report HGA<=12 & HGC<12;

chk_grmon=0; * Indicate cases where GRSURV is coded with the GRSURV at DLI, i.e., grsurvP. In these
cases we must check whether that grade was completed by June of 2004 to ensure that
coding GRMON also by grsurvP is correct.;

hgc_hga=0; * Indicates if Rs reporting HGC greater than HGA;

hgc_hga_n=-4; * Indicates if Rs reporting HGC greater than HGA, after HGC and HGA were edited for those
never enrolled at or since DLI such that they remained the same as those at DLI.;

**************************************************************
** dlicm: date of last interview **
** dli_rnd: the last round that R was interviewed **
** doicm: date of current interview **
** enroll_Rx: whether enrolled in earlier rounds **
** encatP: ENCAT when last interviewed **
** hgaloop: highest grade attended (from loops) **
** hgcloop: highest grade completed (from loops) **
** hgcdt: date of completion of hgcloop **
**************************************************************;

MONYR=308;
YEAR=2005;
MONTH=8;
doicm_LR=doicmr8;

*** Define arrays to be used later in the program;
array scode (4) scoder9_1-scoder9_4;
array e27337 (4) e27337r9_1-e27337r9_4;
array strtm (6) strtmr9_11-strtmr9_14 strtmr9_21 strtmr9_31;
array strty (6) strtyr9_11-strtyr9_14 strtyr9_21 strtyr9_31;
array stopm (6) stopmr9_11-stopmr9_14 stopmr9_21 stopmr9_31;
array stopy (6) stopyr9_11-stopyr9_14 stopyr9_21 stopyr9_31;
array degre (6) e27337r9_1-e27337r9_4 e27337r9_1 e27337r9_1;
array codes (6) scoder9_1-scoder9_4 scoder9_1 scoder9_1;
array reasn (6) lftscr9_1-lftscr9_4 lftsc2r9_1 lftsc3r9_1;
array strcm (6) strcm11-strcm14 strcm21 strcm31;
array stpcm (6) stpcm11-stpcm14 stpcm21 stpcm31;

* Start month from roster;
array oldstrtm (4) strtmr9_11 strtmr9_12 strtmr9_13
strtmr9_21;

* Start year from roster;
array oldstrty (4) strtyr9_11 strtyr9_12 strtyr9_13
strtyr9_21;

* Corrected start month;
array e8774m (4) e8774mr9_11 e8774mr9_21 e8774mr9_31
e8774mr9_12;

* Corrected start year;
array e8774y (4) e8774yr9_11 e8774yr9_21 e8774yr9_31
e8774yr9_12;

* Grades attended;
array gratnd (13) e8416r9_11 e8416r9_12 e8416r9_21 e8416r9_31
e9589r9_111-e9589r9_113 e9589r9_211-e9589r9_213
e9589r9_311-e9589r9_313;

* Grade completed;
array grcomp (13) e9131r9_11 e9131r9_12 e9131r9_21 e9131r9_31
e9946r9_111-e9946r9_113 e9946r9_211-e9946r9_213
e9946r9_311-e9946r9_313;

* start date - year;
array yrstrt (13) e8774yr9_11 e8774yr9_12 e8774yr9_21 e8774yr9_31
e9691yr9_111-e9691yr9_113 e9691yr9_211-e9691yr9_213
e9691yr9_311-e9691yr9_313;

* start date - month;
array mostrt (13) e8774mr9_11 e8774mr9_12 e8774mr9_21 e8774mr9_31
e9691mr9_111-e9691mr9_113 e9691mr9_211-e9691mr9_213
e9691mr9_311-e9691mr9_313;

* Date of completion - year;
array yrcomp (13) e9335yr9_11 e9335yr9_12 e9335yr9_21 e9335yr9_31
e10099yr9_111-e10099yr9_113 e10099yr9_211-e10099yr9_213
e10099yr9_311-e10099yr9_313;

* Date of completion - month;
array mocomp (13) e9335mr9_11 e9335mr9_12 e9335mr9_21 e9335mr9_31
e10099mr9_111-e10099mr9_113 e10099mr9_211-e10099mr9_213
e10099mr9_311-e10099mr9_313;

array t7000A (*) t7000:;
array e6784 (3) e6784r9_1-e6784r9_3;
array e6938 (3) e6938r9_1-e6938r9_3;
array e7192 (3) e7192r9_1-e7192r9_3;
array e7142 (3) e7142r9_11 e7142r9_21 dum;
array e6943 (3) e6943r9_11 e6943r9_21 dum;
array doicmR (8) doicmr1-doicmr8;
array intmR (8) intmr1-intmr8;
array intyR (8) intyr1-intyr8;
array encatR (8) encatr1-encatr8;
array enrollR (8) enrollr1-enrollr8;
array grsurvR (8) grsurvr1-grsurvr8;
array grmonR (8) grmonr1-grmonr8;
array graugR (8) graugr1-graugr8;
array degsurvR (8) degsurvr1-degsurvr8;
array grsurvFR (8) grsurvFr1-grsurvFr8;
array hgaR (8) e3500r1 e2857r2-e2857r8;
array hgcR (8) e5000r1 e3112r2-e3112r8;
array hsrR (8) hsr1-hsr8;
array gdrR (8) gdr1-gdr8;

array scoder [8,7] scoder1_1 dum dum dum dum dum dum
scoder2_1-scoder2_6 dum
scoder3_1-scoder3_7
scoder4_1-scoder4_5 dum dum
scoder5_1-scoder5_6 dum
scoder6_1-scoder6_4 dum dum dum
scoder7_1-scoder7_5 dum dum
scoder8_1-scoder8_5 dum dum;

*** HAND EDIT (1);
if pubid=413 then do;
stopmr9_11=11;
end;

*** Create intermediate variables to be used in the program later.;
do i=1 to dim(oldstrtm);
if e8774y(i)<=0 then do;
e8774y(i)=oldstrty(i);
e8774m(i)=oldstrtm(i);
end;
end;

** Checking int dates;
if e3112r9~=-5 then doicmr9=((intyr9-1980)*12)+intmr9;
if doicmr9~=-5 then doicm=doicmr9;

* Whether received GED, ever;
if CDTGD>-4 then GED=1;
* Whether received HS Diploma, ever;
if CDTHS>-4 then HSD=1;
* Whether received both GED and HS Diploma, ever;
if HSD=1 & GED=1 then both=1;

* Compute dlicm and dli_rnd;
do j=1 to dim(doicmR);
if doicmR(j)~=-5 then do;
dlicm=doicmR(j);
dlim=intmr(j);
dliy=intyr(j);
dli_rnd=j;
do k=1 to 7;
if scoder(j,k) in (4,5) then ever_24yrinst=1;
end;
hsrP=hsrR(j);
gdrP=gdrR(j);
grsurvFP=grsurvFR(j);
end;
end;
if HSD=0 & hsrP>-4 then hsrP=-4;
if GED=0 & gdrP>-4 then gdrP=-4;

* Enrollment status at each interview and ENCAT at last interview;
do i=1 to dim(doicmR);
if encatR(i) in (8,9,10,11) then enrollR(i)=1;
if encatR(i) in (1,2,3,4,5,6,7) then enrollR(i)=0;
if -5<encatR(i)<0 then enrollR(i)=encatR(i);
if encatR(i)~=-5 then encatP=encatR(i);
if enrollR(i)~=-5 then enrollP=enrollR(i);
if enrollR(i)=1 then last_enr=i;
if hgaR(i)~=-5 then hgaP=hgaR(i);
end;

* Create variable indicating HGC by DLI;
do i=1 to dim(grsurvR);
if grsurvR(i)>-5 then grsurvP=grsurvR(i);
if grmonR(i)>-5 then grmonP=grmonR(i);
if graugR(i)>-5 then graugP=graugR(i);
end;
grsurvP_no3061=grsurvP;
if e3061r9>0 & GED=0 then grsurvP=e3061r9;
if e3061r9>0 & GED=1 & e3061r9~=12 then grsurvP=e3061r9;
if grsurvP<grmonP<95 then grmonP=grsurvP;

* Create variable indicating Highest Degree Received by DLI;
do i=1 to dim(degsurvR);
if degsurvR(i)~=-5 then degsurvP=degsurvR(i);
end;

* Expected date of graduation;
if e24889mr9>-4 & e24889yr9>-4 then do;
gradyr9=e24889yr9;
gradmr9=e24889mr9;
if e24889mr9>0 & e24889yr9>0 then gradcm=(((e24889yr9-1980)*12)+e24889mr9);
if -3<=e24889mr9<=-1 & e24889yr9>0 then gradcm=(((e24889yr9-1980)*12)+6);
if -3<=e24889yr9<=-1 then gradcm=-3;
if intmr9<5 then do;
if gradyr9=intyr9+0 then expcurrgr=11;
if gradyr9=intyr9+1 then expcurrgr=10;
if gradyr9=intyr9+2 then expcurrgr=9;
if gradyr9=intyr9+3 then expcurrgr=8;
if gradyr9=intyr9+4 then expcurrgr=7;
end;
if intmr9>=8 then do;
if gradyr9=intyr9+1 then expcurrgr=11;
if gradyr9=intyr9+2 then expcurrgr=10;
if gradyr9=intyr9+3 then expcurrgr=9;
if gradyr9=intyr9+4 then expcurrgr=8;
if gradyr9=intyr9+5 then expcurrgr=7;
end;
end;
if e24940mr9>-4 & e24940yr9>-4 then do;
gradyr9=e24940yr9;
gradmr9=e24940mr9;
if e24940mr9>0 & e24940yr9>0 then gradcm=(((e24940yr9-1980)*12)+e24940mr9);
if -3<=e24940mr9<=-1 & e24940yr9>0 then gradcm=(((e24940yr9-1980)*12)+6);
if -3<=e24940yr9<=-1 then gradcm=-3;
if intmr9<8 then do;
if gradyr9=intyr9+1 then expcurrgr=11;
if gradyr9=intyr9+2 then expcurrgr=10;
if gradyr9=intyr9+3 then expcurrgr=9;
if gradyr9=intyr9+4 then expcurrgr=8;
if gradyr9=intyr9+5 then expcurrgr=7;
end;
if intmr9>=8 then do;
if gradyr9=intyr9+2 then expcurrgr=11;
if gradyr9=intyr9+3 then expcurrgr=10;
if gradyr9=intyr9+4 then expcurrgr=9;
if gradyr9=intyr9+5 then expcurrgr=8;
if gradyr9=intyr9+6 then expcurrgr=7;
end;
end;

** Start and stop dates of enrollment in continuous month scheme;
do i=1 to dim(degre);
if stopm(i)>0 & stopy(i)>0 then stpcm(i)=((stopy(i)-1980)*12)+stopm(i);
if -4<stopm(i)<0|-4<stopy(i)<0 then stpcm(i)=-3;
if strtm(i)>0 & strty(i)>0 then strcm(i)=((strty(i)-1980)*12)+strtm(i);
if -4<strtm(i)<0|-4<strty(i)<0 then strcm(i)=-3;
end;

** Data and quex problems w/ roster information;
rosprb1=0; rosprb2=0;
do i=1 to dim(scode);
if (scode(i)=4|scode(i)=5) & e27337(i)=-4 then rosprb1=1;
if scode(i)=-4 & e27337(i)>-4 then rosprb2=1;
if scode(i) in (-2,-3) then INV1=1;
if scode(i) in (4,5) & e27337(i) in (-2,-3) then INV2=1;
end;
do i=1 to dim(strcm);
if strcm(i)=-3 then INV3=1;
if stpcm(i)=-3 then INV3=2;
if strcm(i)=-3 & stpcm(i)=-3 then INV3=3;
end;

* Last regular school enrolled in, its start and stop date of enrollment, type of school and degree
working towards & school loop number;
STOP=-4;
do i=1 to dim(degre);
if stpcm(i)>STOP then do;
STOP=stpcm(i);
STRT=strcm(i);
sch=codes(i);
deg=degre(i);
rosnum=i;
STOP_loc=1;
end;
if stpcm(i)=STOP & sch in (4,5) & codes(i)=sch & deg in (1,3,4,5,6,10) & degre(i)=deg then do;
STOP=stpcm(i);
STRT=strcm(i);
sch=codes(i);
deg=degre(i);
rosnum=i;
STOP_loc=2;
end;
if 0<stpcm(i)<STOP & 0<cdths<STOP & STOP=doicm & 0<STRT<strcm(i) & 0<cdths<=strcm(i)
& codes(i) in (4,5) & sch in (1,2,3) & degre(i) in (1,3,4,5,6,10) & deg not in (1,3,4,5,6,10) then do;
STOP=stpcm(i);
STRT=strcm(i);
sch=codes(i);
deg=degre(i);
rosnum=i;
STOP_loc=3.1;
end;
if 0<stpcm(i)<STOP & 0<cdtgd<STOP & STOP=doicm & 0<STRT<strcm(i) & 0<cdtgd<=strcm(i)
& codes(i) in (4,5) & sch in (1,2,3) & degre(i) in (1,3,4,5,6,10) & deg not in (1,3,4,5,6,10) then do;
STOP=stpcm(i);
STRT=strcm(i);
sch=codes(i);
deg=degre(i);
rosnum=i;
STOP_loc=3.2;
end;
if stpcm(i)=STOP & codes(i)=5 & sch=4 & degre(i) in (1,3,4,5,6,10) & deg in (1,3,4,5,6,10) then do;
STOP=stpcm(i);
STRT=strcm(i);
sch=codes(i);
deg=degre(i);
rosnum=i;
STOP_loc=4;
end;
if stpcm(i)=STOP & codes(i)=5 & sch=5 & degre(i) in (4,5,6,10) & deg in (1,3) then do;
STOP=stpcm(i);
STRT=strcm(i);
sch=codes(i);
deg=degre(i);
rosnum=i;
STOP_loc=5;
end;
if stpcm(i)=STOP & codes(i) in (4,5) & sch in (1,2,3) & (HSD=1|GED=1) then do;
STOP=stpcm(i);
STRT=strcm(i);
sch=codes(i);
deg=degre(i);
rosnum=i;
STOP_loc=6;
end;
if 0<stpcm(i)<=STOP & codes(i)in (1,2,3) & sch in (1,2,3) & STOP=doicm & strcm(i)>=STRT>0 then do;
STOP=stpcm(i);
STRT=strcm(i);
sch=codes(i);
deg=degre(i);
rosnum=i;
STOP_loc=7;
end;
if stpcm(i)=STOP & STOP=doicm & 0<STRT<strcm(i) & codes(i) in (4,5) & sch in (4,5)
& degre(i) in (1,3,4,5,6,10) & deg not in (1,3,4,5,6,10) then do;
STRT=strcm(i);
sch=codes(i);
deg=degre(i);
rosnum=i;
STOP_loc=8;
end;
end;
* dual enrollment - R is enrolled in a high school and college simultaneously.;
do i=1 to dim(degre);
if stpcm(i)=STOP & codes(i) in (1,2,3) & sch in (4,5) & HSD=0 & GED=0 then do;
STOP=stpcm(i);
STRT=strcm(i);
sch=codes(i);
deg=degre(i);
rosnum=i;
STOP_loc=9;
end;
end;

if STOP>0 then diff=doicm-STOP;
do i=1 to dim(degre);
if rosnum=i then do;
if STOP=doicm & stpcm(i)=doicm & reasn(i)>-4 then diff=10000;
end;
end;
do i=1 to dim(degre);
if strcm(i)>=-3 & stpcm(i)>=-3 then lastloopnum=i;
end;

* Whether the last school attended was High School or College, and if the latter then for what degree;
if sch in (-1,-2,-3) then lastsch=-3;
if sch=6 then lastsch=6;
if sch in (1,2,3) then lastsch=1;
if sch in (4,5) and deg in (1,3,4,5,6,10) then lastsch=2;
if sch in (4,5) and deg in (2,7,8,999) then lastsch=2.1;
if sch in (4,5) and deg=9 then lastsch=2.2;
if sch in (4,5) and deg in (-1,-2,-3) then lastsch=2.3;
if sch in (4,5) and deg=-4 then lastsch=2.4;

** Hand edits;
if pubid in (420 430 1557 4293 4294  4793 5408 5840 6023 6719
 7035 7186 7221 7235 7974 8870) then do;
lastsch=2;
deg=3;
currcoll=1;
end;
if pubid in (2311 2744 4558 8232 9008) then do;
lastsch=2;
deg=1;
currcoll=1;
end;
if pubid=4136 then do;
lastsch=2;
deg=4;
currcoll=1;
end;
if pubid in (1687 3287 4281 7143) then do;
lastsch=2;
deg=3;
sch=5;
currcoll=1;
end;
if pubid in (794 327 7373 8284) then do;
lastsch=2;
deg=4;
sch=5;
currcoll=1;
end;
if pubid in (3786) then do;
lastsch=2;
deg=6;
sch=5;
currcoll=1;
end;
if pubid in (1843) then do;
lastsch=2.1;
end;

if lastsch=6 & deg in (4,5,6,10) & CDTBA>-4 then do;
sch=5;
lastsch=2;
end;

* R attended college (in a degree program) in a previous round;
do i=1 to dim(encatR);
if encatR(i) in (4,5,6,7,9,10,11) & degsurvR(i)>=1 then prevcoll=1;
if encatR(i) in (4,5,6,7,9,10,11) & degsurvR(i)<1 then do;
prevcoll=1;
chk_commP=1;
if hsrR(i)>-4|gdrR(i)>-4 then chk_commP=2;
end;
end;

* R attended college (in a degree program) in a previous round and did not correct HGA as of
last interview (e2806) to <13 i.e. accepts being in college as of last interview;
do i=1 to dim(encatR);
if (e2806r9=-4|e2806r9>=13) & encatR(i) in (4,5,6,7,9,10,11) & (hsrR(i)=1|gdrR(i)=1) then prevcoll=1;
if (e2806r9=-4|e2806r9>=13) & encatR(i) in (4,5,6,7,9,10,11) & hsrR(i)=-4 & gdrR(i)=-4 then do;
prevcoll=1;
chk_commP=1;
if 0<CDTHS<=doicmR(i) then chk_commP=2;
if 0<CDTGD<=doicmR(i) then chk_commP=2;
end;
end;

* When R attended college (in a degree program) in this round;
do i=1 to dim(scode);
if scode(i) in (4,5) & e27337(i) in (1,3,4,5,6,10) then currcoll=1;
end;
if hsd=0 & ged=0 & currcoll=1 then chk_comm=1;
if hsd=0 & ged=0 & currcoll=1 & clg_ok=-4 then clg_ok=0;
if (hsd=1|ged=1) & currcoll=1 then clg_ok=1;
if prevcoll=1|currcoll=1 then somecoll=1;

*** Hand edits.;
if pubid in (397 698 1115 1150 1436 1828 1890 2446 2645 2652
2652 3002 3011 3167 3231 3252 3356 3830 4126 4148
4151 4202 4287 4532 4587 4655 4958 5050 5648 5685
5886 6146 6168 6199 6299 6338 6628 6826 6994 7070
7107 7153 7315 7327 7355 7652 7844 7888 7973 8126
8242 8295 8296 8696 8698 8484 8859) & currcoll=1 & clg_ok~=1 then do;
clg_ok=1;
FLG_13900r9=2;
end;

if pubid in (81 100 273 1260 2122 3290 4396 4650 5039 5499
5684 5807 5929 6482 6491 6505 6876 7156 7424
7632 7828 8182 8281 9018) & clg_ok=1 then do;
clg_ok=0;
FLG_13900r9=3;
end;

* Grade information from loops;
hgaloop=e8416r9_11;
do i=2 to dim(gratnd);
if gratnd(i)>hgaloop then do;
hgaloop=gratnd(i);
end;
end;

hgcloop=-16;
do i=1 to dim(gratnd);
if gratnd(i)>=0 & gratnd(i)>hgcloop then do;
if grcomp(i)=1 then do;
hgcloop=gratnd(i);
if mocomp(i)>0 & yrcomp(i)>0 then hgcdt=((yrcomp(i)-1980)*12)+mocomp(i);
if mocomp(i)>0 & yrcomp(i)>0 then hgcdt=-3;
end;
else if grcomp(i) in (-1,-2,-3) then do;
hgcloop=grcomp(i);
end;
end;
if gratnd(i) in (0,-1, -2, -3,-4) & grcomp(i)>-4 then do;
hgcloop=-55;
end;
end;

if (1<=e2857r9<=12) & HSD=0 & GED=0 then hgsch=1;

do i=1 to dim(scode);
if scode(i) in (1,2,3) then attsch=1;
end;

do i=1 to dim(e27337);
if e27337(i) in (1,3) then college=1;
if e27337(i) in (4,5,6,10) then college=2;
if e27337(i) in (-1,-2,-3) then college=-3;
end;

if 0<=e2857r9<e3112r9<95 then hgc_hga=1;
if (0<=e2857r9<12) & e3112r9=12 then hgc_hga=2;
if 0<=e2857r9<=12<e3112r9<95 & hsd=0 & ged=0 then hgc_hga=3.1;
if 0<=e2857r9<=12<e3112r9<95 & (hsd=1|ged=1) then hgc_hga=3.2;
if 12<e2857r9<e3112r9<95 then hgc_hga=4;

** When R was not enrolled at DLI and has not been enrolled since DLI, impute HGA (YSCH-2857)
and HGC (YSCH-3112) as that reported at DLI unless corrected.;
if e3878r9=0 & hgc_hga>=1 then do;
hgc_hga_n=0;
if e3103r9~=0 then e2857r9=hgaR(dli_rnd);
if e3103r9=0 then e2857r9=e3104r9;
if e3010r9~=0 then e3112r9=hgcR(dli_rnd);
if e3010r9=0 then e3112r9=e3061r9;
if 0<=e2857r9<e3112r9<95 then hgc_hga_n=1;
end;

********************************************************************************************************
*** (I) CREATED VARIABLE - ENROLLMENT STATUS (ENCAT) ***
********************************************************************************************************;

*** [IA] Determining whether the respondent is enrolled or not. Note: Summer vacations are included as part of the enrollment period;

if diff=0 then ENROLL=1;
if diff>0 then ENROLL=0;
if -3<=STOP<=-1 then ENROLL=0;
if e3878r9=0 then ENROLL=0;

** If respondent has received a H.S. Diploma, HGA & HGC is 12 and there is a valid end date for
the completed 12th grade then check whether R should be coded as enrolled or not. If R reports
a 2-yr or 4-yr college then R is coded as enrolled irrespective of the type of degree working
towards;

if HSD=1 & hgcloop=12 & hgcdt>0 & ENROLL=1 then do;
chk_enr2=1;
ENROLL=0;
do i=1 to dim(scode);
if scode(i) in (4,5) then ENROLL=1;
end;
end;

** Computing ENROLL by another method - ENROLLx;
if e1624r9_1=1 then flagloop=1; * flag those who re-enroll;

** not enrolled at and sdli;
if e3878r9=0 then enrollx=0;

** old school;
* enrolled at dli, continuously enrolled in old school sdli, no new schools;
if e4795r9=1 & e4951r9=0 then enrollx=1;
* not enrolled at dli but re-enrolled in old school sdli, continuously re-enrolled in old school
sdli, no new schools;
if e4793r9=1 & e4951r9=0 then enrollx=1;
* not continuously enrolled in old school SDLI;
if (e4795r9=0 or e4793r9=0) then do;
*left school upon completing coursework or receiving degree;
if e1605r9=-4 & e4951r9=0 then enrollx=0;
* re-enrolled in old school;
if e1605r9=1 then do;
* continuously re-enrolled in old school, no new schools;
if e1615r9_1=1 & e4951r9=0 then enrollx=1;
* not continuously re-enrolled in old school, first time through loop, no other re-enrollments
at old school, and no new schools;
if e1615r9_1=0 & e1624r9_1=0 & e1627r9_1=0 & e4951r9=0 then enrollx=0;
* continuously re-re-enrolled in old school, no new schools;
if e1615r9_2=1 & e4951r9=0 then enrollx=1;
* not continuously re-re-enrolled in old school, second time through loop;
if e1615r9_2=0 then chk_enrprd=1;
end;
* not re-enrolled in old school, no new schools;
if e1605r9=0 and e4951r9=0 then enrollx=0;
end;

** new school;
* enrolled or not enrolled at dli but enrolled in new school sdli;
if (e4951r9=1 or e3878r9=1) then do;
* continuously enrolled in new school, no other new schools reported;
do i=1 to dim(e6784);
if e6784(i)=1 & e7192(i)=0 then enrollx=1;
end;
* not continuously enrolled in new school, re-enrolled, continuously re-enrolled, no other
new schools reported;
do i=1 to dim(e6784);
if e6784(i)=0 & e7192(i)=0 then do;
if e6943(i)=1 then enrollx=1;
end;
end;
* not continuously enrolled in new school -
(1) re-enrolled, not continuously re-enrolled
(2) left school because completed coursework or received degree,
No other enrollment periods, no other new school;
do i=1 to dim(e6784);
if e7142(i)=0 & e7192(i)=0 then enrollx=0;
end;
* not continuously enrolled in new school, did not re-enroll, no new schools;
do i=1 to dim(e6784);
if e6938(i)=0 & e7192(i)=0 then enrollx=0;
end;
end;

*** (IB) Determining the sub-categories of not enrolled;
if ENROLL=0 then do;

** No H.S. Diploma, no GED - ENCAT=1;
if (GED<=0) & (HSD<=0) then ENCAT=1;

** GED - ENCAT=2;
if GED=1 then ENCAT=2;

** High school degree - ENCAT=3;
if HSD=1 then ENCAT=3;

** R (now not enrolled) attended some college & was enrolled in a degree program.
Note: those who indicated attending a college and working toward a "vocational or technical
certificate" (e27337=2) are coded as not having attended college as these credits
typically won't transfer into a BA or an AA Degree. R attended some college,
perhaps in a prior round, or in current round;
if prevcoll=1 then ENCAT=4;
if currcoll=1 & ((13<=e2857r9<=20)|e3112r9>=12|HSD=1|GED=1|hgcloop=12|clg_ok=1) then ENCAT=4;

** Received junior college or 2 year associate degree - ENCAT=5;
if CDTAA>-4 then ENCAT=5;

** Received bachelor's degree - ENCAT=6;
if CDTBA>-4 then ENCAT=6;

** Received master's, doctoral or professional degree - ENCAT=7;
if CDTMA>-4|CDTDC>-4|CDTPF>-4 then ENCAT=7;
end;

*** (IC) Determining the sub-categories of enrolled;
if ENROLL=1 then do;

if lastsch=1 then do;
if CDTHS>0 & (e3112r9=12|hgcloop=12) then flaghs=1;
if (1<=e2857r9<=12) & HSD<=0 & GED<=0 then ENCAT=8;
if e2857r9=13 & HSD=0 & GED=0 then ENCAT=8;
if e2857r9=95 & HSD=0 & GED=0 then do;
ENCAT=8;
ungraded=1;
end;
end;

if lastsch=2 then do;
if sch=4 & deg in (1,3,4,5,6,10) & ((13<=e2857r9<95)|e3112r9>=12|GED=1|HSD=1|hgcloop=12|clg_ok=1)
then ENCAT=9;
if sch=5 & deg in (1,3,4,5,6,10) & ((13<=e2857r9<95)|e3112r9>=12|GED=1|HSD=1|hgcloop=12|clg_ok=1)
then ENCAT=10;
if sch=5 & deg in (4,5,6,10) & ((16<e2857r9<95)|e3112r9>=16) then ENCAT=11;
if sch=5 & deg in (4,5,6,10) & CDTBA>-4 then ENCAT=11;
if (1<=e2857r9<=12) & HSD=0 & GED=0 & clg_ok~=1 then do;
ENCAT=8;
flagcoll=1;
end;
end;

if lastsch>2 then do;
if GED=0 & HSD=0 & somecoll=0 then ENCAT=8;
if currcoll=0 & prevcoll=1 then do;
ENCAT=4;
if CDTAA>-4 then ENCAT=5;
if CDTBA>-4 then ENCAT=6;
if CDTMA>-4|CDTDC>-4|CDTPF>-4 then ENCAT=7;
end;
if currcoll=1 & (HSD=1|GED=1|clg_ok=1) then ENCAT=4;
end;
if GED=1 & HSD=0 & somecoll=0 then ENCAT=2;
if HSD=1 & somecoll=0 then ENCAT=3;
if (HSD=1|GED=1|clg_ok=1) & currcoll=1 & lastsch=-3 then ENCAT=4;
if (HSD=1|GED=1) & prevcoll=1 & lastsch=-3 then ENCAT=4;
if CDTAA>-4 & somecoll=1 & lastsch=-3 then ENCAT=5;
if CDTBA>-4 & somecoll=1 & lastsch=-3 then ENCAT=6;
end;

** Respondents receiving the bachelor's degree degree in and around the month of the interview are
coded as being enrolled by the program. ENCAT needs to be recoded;
if CDTHS>0 & doicm=CDTHS & ENCAT in (-3,1,2,8) then do;
ENCAT=3;
same_mth=1;
end;

if CDTGD>0 & doicm=CDTGD & ENCAT in (-3,1,8) then do;
ENCAT=2;
same_mth=1;
end;

if CDTAA>0 & doicm=CDTAA & ENCAT in (-3,1,2,8,3,4,9) then do;
ENCAT=5;
same_mth=1;
end;

if CDTBA>0 & doicm=CDTBA & ENCAT in (-3,1,2,8,3,4,5,10) then do;
ENCAT=6;
same_mth=1;
end;

if ((CDTMA>0 & doicm=CDTMA)|(CDTDC>0 & doicm=CDTDC)) & ENCAT~=7 then do;
ENCAT=7;
same_mth=1;
end;

** If R was enrolled since DLI although may not be currently enrolled;
if ENROLL=1|(ENROLL=0 & e3878r9~=0) then do;

* MISSING VALUES;
if lastsch=-3 & ENCAT<0 then do;
ENCAT=-3;
reason=1;
end;

if INV2=1 then do;
flagcoll=-3;
college=-3;
if enroll=1 & lastsch=2.3 then do;
ENCAT=-3;
reason=2.1;
end;
if enroll=0 & somecoll=0 & lastsch=2.3 then do;
ENCAT=-3;
reason=2.2;
end;
end;

* Those who completed high school (or a GED), report HGA>12 but do not identify a college.;
if (HSD=1|GED=1) & (13<=e2857r9<95) & (13<=e3112r9<95) then do;
tmpvar1=ENCAT;
tmpvar2=reason;
ENCAT=-3;
reason=3;
do i=1 to dim(scode);
if scode(i) in (-1,-2,-3,4,5,6) then do;
ENCAT=tmpvar1;
reason=tmpvar2;
end;
end;
end;

* If R has neither GED nor H.S. Diploma but reports going to a college, in a degree program,
& HGA>=13 - hand edit these cases if Rs are in a degree program;
if (13<=e2857r9<=20) & GED=0 & HSD=0 & clg_ok~=1 & currcoll=1 then do;
ENCAT=-3;
reason=5;
end;

* Those who reported being in a 2-yr or 4-yr college but were not asked what type of degree
working towards;
if rosprb1=1 & ENCAT=-3 & reason=. then reason=6;
end;

** HAND EDITS (2);
if pubid= 2122 then do;
ENCAT=1;
reason=7;
handedit=1;
end;
if pubid in (1642 5790 5879 7190 7687) then do;
HE9_EN=ENCAT;
ENCAT=6;
end;

if pubid= 6482 then do;
HE9_EN=ENCAT;
ENCAT=8;
end;
if pubid= 7465 then do;
HE9_EN=ENCAT;
ENCAT=-3;
end;
if pubid= 7481 then do;
HE9_EN=ENCAT;
ENCAT=8;
end;
if pubid= 8385 then do;
HE9_EN=ENCAT;
ENCAT=8;
end;
if pubid= 1561 then do;
HE9_EN=ENCAT;
ENCAT=1;
end;

** These are cases where Respondents
(1) graduated from high school with a high school diploma
(2) enrolled in a two-year or four-year college
(3) HGA>=13
(4) degree working towards is Don't Know
(5) In the next/previous round they report enrollment at this college and working towards a BA or AA
degree.
We assign them the college enrollment.;
if pubid in (759 1964 2932) then do;
HE5_EN=ENCAT;
ENCAT=9;
end;

** Not sure whether these Rs did receive a H.S. Diploma or not;
if pubid in (101 510 3098 4433 7725 7929 3793 4682 4999 5225
7179 8873 205 8114 8088 19 65 2810 1792) & ENCAT=3 then do;
HE9_EN=ENCAT;
ENCAT=-3;
end;
 

if pubid= 7391 & ENCAT=2 then do;
HE9_EN=ENCAT;
ENCAT=-3;
end;
if pubid in (6482 7632 3301 7743) then do;
HE9_EN=ENCAT;
ENCAT=2;
end;
if pubid= 331 then do;
HE9_EN=ENCAT;
ENCAT=9;
end;
if pubid in (6736 1843 6153) then do;
HE9_EN=ENCAT;
ENCAT=-3;
end;
if pubid in (2922 8459) then do;
HE9_EN=ENCAT;
ENCAT=3;
end;

oldENCAT=ENCAT;
oldenroll=enroll;

********************************************** SECTION II **********************************************;
** Must fix "ENROLL" flag because this flag is used in the grades skipped/repeated program;
if ENCAT in (1,2,3,4,5,6,7) & ENROLL~=0 then do;
ENROLL=0;
enr_chg=1;
end;
if ENCAT in (8,9,10,11) & ENROLL~=1 then do;
ENROLL=1;
enr_chg=2;
end;

** Arrays to be used in the rest of the program;
* Grades attended;
array gratnd (13) e8416r9_11 e8416r9_12 e8416r9_21 e8416r9_31
e9589r9_111-e9589r9_113 e9589r9_211-e9589r9_213
e9589r9_311-e9589r9_313;

* Grade completed;
array grcomp (13) e9131r9_11 e9131r9_12 e9131r9_21  e9131r9_31
e9946r9_111-e9946r9_113 e9946r9_211-e9946r9_213
e9946r9_311-e9946r9_313;

* start date - year;
array yrstrt (13) e8774yr9_11 e8774yr9_12  e8774yr9_21 e8774yr9_31
e9691yr9_111-e9691yr9_113 e9691yr9_211-e9691yr9_213
e9691yr9_311-e9691yr9_313;

* start date - month;
array mostrt (13) e8774mr9_11 e8774mr9_12  e8774mr9_21 e8774mr9_31
e9691mr9_111-e9691mr9_113 e9691mr9_211-e9691mr9_213
e9691mr9_311-e9691mr9_313;

* Date of completion - year;
array yrcomp (13) e9335yr9_11 e9335yr9_12  e9335yr9_21 e9335yr9_31
e10099yr9_111-e10099yr9_113 e10099yr9_211-e10099yr9_213
e10099yr9_311-e10099yr9_313;

* Date of completion - month;
array mocomp (13) e9335mr9_11 e9335mr9_12  e9335mr9_21 e9335mr9_31
e10099mr9_111-e10099mr9_113 e10099mr9_211-e10099mr9_213
e10099mr9_311-e10099mr9_313;

array e23450 (4) e23450r9_1-e23450r9_4;
array e27337 (4) e27337r9_1-e27337r9_4;
array scode (4) scoder9_1-scoder9_4;

maxgrade=-16;
comp_mo=-16;
comp_yr=-16;

evrloop=0; * Flag to indicate respondents who go through a grade loop at least once;
subsitm=0; * Flag to indicate e3112 (single item) is being used to compute GRSURV;
subhgam=0; * Flag to hgaloop (HGA from loop) minus 1 is being used to compute GRSURV;
subprev=0; * Flag to indicate grade from last interviewed round is being used to compute GRSURV;
setto12=0; * Flag to indicate GRSURV being set to 12;

dateitm=0; * Flag to indicate date of grade completion missing;
disagre=0; * Flag to indicate that GRSURV from previous rounds is greater than from the current round;
datedeg=0; * Flag to indicate date of degree received is invalid;
mxg_inv=0; * Flag to indicate that the completed grade from loops is 0 or invalid;

********************************************************************************************************
*** [II] CREATED VARIABLE - HIGHEST GRADE COMPLETED AS OF THE SURVEY DATE (GRSURV) ***
********************************************************************************************************;

*** [IIA] Enrolled or not enrolled;
** Compute maximum grade completed using information in this round (grade loops);
do i=1 to dim(gratnd);
if gratnd(i)>=0 & gratnd(i)>maxgrade then do;
if grcomp(i)=1 then do;
maxgrade=gratnd(i);
comp_mo=mocomp(i);
comp_yr=yrcomp(i);
end;
if grcomp(i) in (-1,-2,-3) then mxg_inv=1; *maxgrade=grcomp(i);
end;

** If the grade attended is not valid;
if gratnd(i) in (0,-1,-2,-3,-4) then do;
if grcomp(i)=1 then do;
mxg_inv=2;
maxgrade=-55;
end;
if grcomp(i) in (-1,-2,-3) then mxg_inv=3;
end;
if grcomp(i)>-4 then evrloop=1;
end;

do i=1 to dim(gratnd);
if gratnd(i)>=0 & gratnd(i)>CJUGR then do;
if grcomp(i)=1 then do;
if (0<yrcomp(i)<YEAR)|(yrcomp(i)=YEAR & 0<mocomp(i)<=MONTH) then do;
CJUMON=mocomp(i);
CJUYR=yrcomp(i);
CJUGR=gratnd(i);
GRMON=gratnd(i);
GRAUG=gratnd(i);
LOC=1000.1;
LOCA=1000.1;
end;
end;
end;
end;

** If same grade is reported more than once.;
do i=1 to dim(gratnd);
if gratnd(i)>=0 & gratnd(i)=maxgrade & grcomp(i)=1 then do;
if comp_yr>0 & comp_mo<0 & mocomp(i)>0 & comp_yr=yrcomp(i) then do;
comp_mo=mocomp(i);
end;
if comp_yr<0 & mocomp(i)>0 & yrcomp(i)>0 then do;
comp_mo=mocomp(i);
comp_yr=yrcomp(i);
end;
if comp_yr>0 & comp_mo>0 & mocomp(i)>0 & yrcomp(i)>0
& (comp_yr~=yrcomp(i)|comp_mo~=mocomp(i))
then do;
if yrcomp(i)>comp_yr then do;
comp_mo=mocomp(i);
comp_yr=yrcomp(i);
end;
if yrcomp(i)=comp_yr & mocomp(i)>comp_mo then do;
comp_mo=mocomp(i);
end;
end;
end;
end;

** If one grade is completed in September of YEAR and the next grade also starts in September of YEAR.;
do i=1 to dim(gratnd);
if maxgrade>=0 & comp_mo=9 & comp_yr=YEAR & gratnd(i)=maxgrade+1 & mostrt(i)=9 & yrstrt(i)=YEAR
then do;
CJUMON=8;
CJUYR=YEAR;
CJUGR=maxgrade;
GRMON=maxgrade;
GRAUG=maxgrade;
LOC=1.6;
LOCA=1.6;
end;
end;

** Make GRSURV equal to maximum completed grade reported in the loops;
GRSURV=maxgrade;
LOCATOR=1;

** R reports YSCH-3112 to be in (1,2,3,4) and as being in college;  R is reporting the
completed years of college rather than years of schooling. Here we identify these cases;
if ENCAT in (4,5,6,7,9,10,11) & e3112r9 in (1,2,3,4,5,6) then do;
inclg_lowHGC=1;
e3112r9_imp=e3112r9+12;
end;

** If invalid or incorrect grade data was read into loop or if R never goes through the loops and
they attended school at some time either at DLI or SDLI, then replace GRSURV with single item;
if (GRSURV=-55|evrloop=0) & e3878r9~=0 & e3112r9~=-4 then do;
subsitm=1;
if clg_ok~=1 then do;
GRSURV=e3112r9;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=2.1;
LOC=2.11;
LOCA=2.11;
if CJUGR>0 & CJUMON<=MONTH & CJUYR=YEAR then do;
GRMON=CJUGR;
GRAUG=CJUGR;
LOC=2.12;
LOCA=2.12;
end;
end;
if GED=1 & hsrP=-4 & gdrP=-4 & attsch=0 & e3112r9=12 then do;
GRSURV=grsurvP;
GRMON=grsurvP;
GRAUG=grsurvP;
LOCATOR=2.21;
LOC=2.21;
LOCA=2.21;
end;
if HSD=1 & hsrP=-4 & gdrP=-4 & attsch=0 & e3112r9=12 then do;
GRSURV=grsurvP;
GRMON=grsurvP;
GRAUG=grsurvP;
LOCATOR=2.22;
LOC=2.22;
LOCA=2.22;
end;
end;

** If R confirmed completing a grade in the loop & didn't know the year of completion, then
use the loop data or the single item (ysch-3112) whichever is lower.;
if maxgrade=GRSURV & comp_yr=-2 then do;
if maxgrade>e3112r9 & e3112r9>=0 then do;
dateitm=1;
subsitm=1;
GRSURV=e3112r9;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=3;
LOC=3.1;
LOCA=3.1;
end;
end;

if maxgrade=GRSURV & comp_yr~=-2 & comp_mo=-2 then do;
if comp_yr<YEAR then do;
GRMON=GRSURV;
GRAUG=GRSURV;
LOC=3.21;
LOCA=3.21;
end;
if comp_yr>=YEAR then do;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOC=3.22;
LOCA=3.22;
end;
end;

else if (comp_yr~=-2 & comp_mo~=-2) then do;
dateitm=.;
end;

** If R was enrolled SDLI but didn't confirm completing a grade.  If single item HGA and HGA from the
loop are equal then substitute HGC single item if HGA from the loop is higher or equal to the HGC single
item. If GRSURV still cannot be assigned then we use the expected date of graduation and HGC single
item to ascertain if the HGC single item could be correct (and use it).  If GRSURV still cannot be
assigned then we use HGC at DLI if that is greater than the HGC single item.;
if GRSURV=-16 & e3878r9~=0 & evrloop=1 then do;
if hgaloop=e2857r9 & e2857r9>=0 & e3112r9>=0 then do;
if hgaloop=e3112r9|hgaloop=e3112r9+1 then do;
gr_ncomp1=1;
subsitm=1;
GRSURV=e3112r9;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=4.11;
LOC=4.11;
LOCA=4.11;
if gdrP=-4 & GED=1 & e3112r9=12 then do;
GRSURV=grsurvP;
LOCATOR=4.12;
end;
if 0<=e3112r9<GRSURVP then gr_ncomp1=2;
end;
if 0<=GRSURVP<hgaloop<e3112r9 then do;
GRSURV=grsurvP;
GRMON=grsurvP;
GRAUG=grsurvP;
LOCATOR=4.13;
LOC=4.13;
LOCA=4.13;
end;
if hgaloop>e3112r9+1 & e3112r9>GRSURVP>=0 then gr_ncomp1=3;
if hgaloop>e3112r9+1 & 0<=e3112r9<GRSURVP then gr_ncomp1=4;
if hgaloop<e3112r9 & 0<=GRSURVP<=e3112r9 then gr_ncomp2=1;
if hgaloop<e3112r9 & 0<=e3112r9<GRSURVP then gr_ncomp2=2;
end;
if hgaloop~=e2857r9 & e2857r9>=0 & hgaloop>=0 then do;
if hgaloop<e2857r9 then gr_ncomp3=1;
if hgaloop>e2857r9 then gr_ncomp3=2;
end;
end;

if GRSURV=-16 & e3878r9~=0 & evrloop=1 & doicm>0 & gradcm>0 & 0<e3112r9<=12 then do;
if e3112r9=12 & gradcm=doicm then do;
GRSURV=12;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=4.21;
LOC=4.21;
LOCA=4.21;
end;
if e3112r9=12 & gradcm<=doicm+5 & ((gradcm=((intyr9-1980)*12)+5)|(gradcm=((intyr9-1980)*12)+6))
then do;
GRSURV=12;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=4.22;
LOC=4.22;
LOCA=4.22;
end;
* Not enrolled;
if e24889mr9=-4 then do;
if intmr9<8 & (e3112r9=11 & gradyr9=intyr9+1) or (e3112r9=10 & gradyr9=intyr9+2)
or (e3112r9=9 & gradyr9=intyr9+3) or (e3112r9=8 & gradyr9=intyr9+4)
or (e3112r9=7 & gradyr9=intyr9+5) then do;
GRSURV=e3112r9;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=4.23;
LOC=4.23;
LOCA=4.23;
end;
if intmr9>=8 & (e3112r9=11 & gradyr9=intyr9+2) or (e3112r9=10 & gradyr9=intyr9+3)
or (e3112r9=9 & gradyr9=intyr9+4) or (e3112r9=8 & gradyr9=intyr9+5)
or (e3112r9=7 & gradyr9=intyr9+6) then do;
GRSURV=e3112r9;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=4.24;
LOC=4.24;
LOCA=4.24;
end;
end;
* Enrolled;
if e24940mr9=-4 then do;
if intmr9<5 & ((e2857r9=e3112r9+1)|(hgaloop=e3112r9+1))
& (e3112r9=11 & gradyr9=intyr9+0) or (e3112r9=10 & gradyr9=intyr9+1)
or (e3112r9=9 & gradyr9=intyr9+2) or (e3112r9=8 & gradyr9=intyr9+3)
or (e3112r9=7 & gradyr9=intyr9+4) then do;
GRSURV=e3112r9;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=4.25;
LOC=4.25;
LOCA=4.25;
end;
if 5<=intmr9<8 & ((e2857r9=e3112r9)|(hgaloop=e3112r9))
& (e3112r9=11 & gradyr9=intyr9+1) or (e3112r9=10 & gradyr9=intyr9+2)
or (e3112r9=9 & gradyr9=intyr9+3) or (e3112r9=8 & gradyr9=intyr9+4)
or (e3112r9=7 & gradyr9=intyr9+5) then do;
GRSURV=e3112r9;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=4.26;
LOC=4.26;
LOCA=4.26;
end;
if intmr9>=8 & ((e2857r9=e3112r9+1)|(hgaloop=e3112r9+1))
& (e3112r9=11 & gradyr9=intyr9+1) or (e3112r9=10 & gradyr9=intyr9+2)
or (e3112r9=9 & gradyr9=intyr9+3) or (e3112r9=8 & gradyr9=intyr9+4)
or (e3112r9=7 & gradyr9=intyr9+5) then do;
GRSURV=e3112r9;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=4.27;
LOC=4.27;
LOCA=4.27;
end;
end;
end;

if GRSURV=-16 & e3878r9~=0 & evrloop=1 then do;
if 0<=e3112r9<=grsurvP then do;
GRSURV=grsurvP;
GRMON=grsurvP;
GRAUG=grsurvP;
LOCATOR=4.3;
LOC=4.3;
LOCA=4.3;
end;
end;

** If college attendance is not reported in the loops then use should be made of the single item HGC
(e3112), but only if enrollment in a college degree program is reported in the current or previous
round. Use ENCAT to determine whether R was ever in college. Given that R attends college then
(a) if e3112>=12 then set that.
(b) if R reports not attending college in this round but had attended college by DLI then set
to HGC by DLI.
(c) otherwise if e3112<12 and none of the above conditions hold then it is unclear what HGC is so
HGC=-3. Check these cases carefully, using comments to see whether R was actually enrolled in
a degree program in college. If so then leave those cases out.;

if ENCAT in (4,5,6,7,9,10,11) then do;
if 12<e3112r9<95 then do;
subsitm=1;
GRSURV=e3112r9;
LOCATOR=5.11;
end;
if e3112r9=12 & LOCATOR not in (2.21,2.22) then do;
subsitm=1;
GRSURV=e3112r9;
LOCATOR=5.12;
end;
if 0<=e3112r9<12 then do;
inclg_lt12=1;
subsitm=1;
GRSURV=e3112r9;
if e3112r9_imp>12 then GRSURV=e3112r9_imp;
LOCATOR=5.2;
end;
if GED=1 & e3112r9=12 then do;
if maxgrade>=0 then do;
GRSURV=maxgrade;
LOCATOR=5.3;
end;
if maxgrade<0 then do;
GRSURV=grsurvP;
LOCATOR=5.4;
end;
end;
if currcoll=1 & 0<=grsurvP<95 & 0<=e3112r9<95 then inclgCI_grchg=e3112r9-grsurvP;
if currcoll=0 & prevcoll=1 & encatP in (4,5,6,7,9,10,11) & 0<=grsurvP<95 & 0<=e3112r9<95
then inclgDLI_grchg=e3112r2-grsurvP;
end;

** If R reports completing a grade in a previous round that is greater than GRSURV for the current
round and the single item provides a more consistent grade, the single item is used. If the
single item is also inconsistent, then GRSURV value from the previous round is used.
Note: don't use single item if it is greater than 12 and no college is reported;
if 0<grsurvP<95 & 0<GRSURV<grsurvP then disagre=1;

if disagre=1 & (hsrP>-4|gdrP>-4) & GRSURV<12 & grsurvP>=12 then do;
disagre=0.5;
subsprev=1;
GRSURV=grsurvP;
GRMON=grsurvP;
GRAUG=grsurvP;
LOCATOR=6.10;
LOC=6.10;
LOCA=6.10;
end;

if disagre=1 then do;
rnd_dif=(YEAR-1996)-dli_rnd+1;
sitm_pr=e3112r9-grsurvP;
if ENCAT in (1,8,-3) then do;
if ENCAT=-3 then do;
GRSURV=-3;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=6.11;
LOC=6.11;
LOCA=6.11;
end;
if 0<=e3112r9<=12 & (0<=sitm_pr<=rnd_dif|grsurvP=95) then do;
subsitm=1;
GRSURV=e3112r9;
LOCATOR=6.12;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOC=6.12;
LOCA=6.12;
end;
end;

if 12<=grsurvP<95 & ENCAT in (4,5,6,7,9,10,11) & currcoll=1 then do;
GRSURV=grsurvP;
subprev=1;
LOCATOR=6.21;
if 0<=sitm_pr<=rnd_dif then do;
subsitm=1;
GRSURV=e3112r9;
LOCATOR=6.22;
end;
if e3112r9_imp>grsurvP then do;
GRSURV=e3112r9_imp;
LOCATOR=6.23;
end;
end;
end;

if 0<GRSURV<grsurvP<=12 then do;
disagre=2;
if expcurrgr=grsurvP then do;
GRSURV=grsurvP;
GRMON=grsurvP;
GRAUG=grsurvP;
LOCATOR=6.31;
LOC=6.31;
LOCA=6.31;
end;
if expcurrgr=grsurvP+1 & expcurrgr>GRSURV+1 then do;
GRSURV=grsurvP;
GRMON=grsurvP;
GRAUG=grsurvP;
LOCATOR=6.32;
LOC=6.32;
LOCA=6.32;
end;
end;

if 0<grsurvP<95 & 0<GRSURV<grsurvP then do;
disagre=3;
end;

*** [IIB] If not enrolled SDLI;
** Assign previous HGC. If previous HGC is missing, then assign single item (e3112).;
* Note for USER'S GUIDE: every R who reports not being enrolled SDLI is given the HGC at DLI except
for those who report receiving a H.S. Diploma during the interim. The latter are assigned a
highest grade completed of 12. Some of these Rs who were not enrolled SDLI report HGC higher than
HGC from last interview. We do not use this new information for the computation of their HGC as
this information is not consistent.;

if e3878r9=0 & grsurvP>=0 then do;
subprev=1;
GRSURV=grsurvP;
GRMON=grsurvP;
GRAUG=grsurvP;
LOCATOR=7.1;
LOC=7.1;
LOCA=7.1;
end;
if e3878r9=0 & grsurvP<=0 then do;
subsitm=1;
GRSURV=e3112r9;
GRMON=-3;
if e3112r9<=12|e3112r9=95 then GRAUG=-3;
LOCATOR=7.2;
LOC=7.2;
LOCA=7.2;
end;

if 12<GRSURV<95 & ENCAT in (1,2,3,8,-3) then do;
whyover12=1;
end;

if GRSURV=-16 then do;
GRSURV=-3;
GRMON=-3;
GRAUG=-3;
LOCATOR=8.1;
LOC=8.1;
LOCA=8.1;
end;

if GRSURV in (-55,-2,0) then do;
GRSURV=-3;
GRMON=-3;
GRAUG=-3;
LOCATOR=8.2;
LOC=8.2;
LOCA=8.2;
end;

if (hsrP>-4|gdrP>-4) & GRSURV~=grsurvP & 0<GRSURV<12 then do;
if evrloop=0 & grsurvP=grsurvP_no3061 then do;
GRSURV=grsurvP;
GRMON=grsurvP;
GRAUG=grsurvP;
LOCATOR=9.1;
LOC=9.1;
LOCA=9.1;
end;
if evrloop~=0|grsurvP~=grsurvP_no3061 then do;
LOCATOR=9.2;
end;
end;

if GRMON=. then do;
GRMON=-3;
GRAUG=-3;
LOC=9.3;
LOCA=9.3;
end;
if GRMON=-3 then do;
if maxgrade=GRSURV & grsurvP=GRSURV-1 & ((comp_yr=YEAR & comp_mo>MONTH)|comp_yr>YEAR)
& 0<dlicm<MONYR then do;
GRMON=grsurvP;
GRAUG=grsurvP;
LOC=10.1;
LOCA=10.1;
end;
end;
if GRMON=-3 & GRSURV>0 then do;
do i=1 to dim(gratnd);
if GRSURV=gratnd(i)-1 & ((0<yrstrt(i)<YEAR)|(yrstrt(i)=YEAR & 0<mostrt(i)<=MONTH+1)) then do;
GRMON=GRSURV;
GRAUG=GRSURV;
LOC=10.2;
LOCA=10.2;
i=dim(gratnd);
end;
end;
end;
if GRMON=-3 & GRSURV>0 & CJUGR>0 then do;
do i=1 to dim(gratnd);
if CJUGR=gratnd(i)-1 & ((0<yrstrt(i)<YEAR)|(yrstrt(i)=YEAR & 0<mostrt(i)<=MONTH+1)) then do;
GRMON=CJUGR;
GRAUG=CJUGR;
LOC=10.3;
LOCA=10.3;
i=dim(gratnd);
end;
end;
end;
if GRMON=-3 & GRSURV>0 then do;
if 0<STOP<MONYR & sch in (1,2,3) then do;
GRMON=GRSURV;
GRAUG=GRSURV;
LOC=10.4;
LOCA=10.4;
end;
end;
if GRMON=-3 then do;
if maxgrade=GRSURV & grsurvP=GRSURV-2 & ((comp_yr=YEAR & comp_mo>MONTH)|comp_yr>YEAR)
& 0<dlicm<MONYR then do;
GRMON=grsurvP;
GRAUG=grsurvP;
LOC=10.5;
LOCA=10.5;
end;
end;

** When we use the single item (YSCH-3112) to get GRSURV we are unable to verify whether the date of
completion for this grade was by Aug of 1999 and so we give a -3 for GRMON. However,
(1) if these are diff1gr cases and we find that maxgrade=YSCH-3112 and the date of completion
of this grade (maxgrade) is by Aug of 1999 then we can assign YSCH-3112 (=maxgrade) to be
GRMON
(2) if the date of grade completion (from loops) is Aug of 1998 be almost sure that the person
could not have completed another grade in that year and so take GRMON to be that grade
completed on Aug of 1998. Note: This situation arises only for diff1gr cases;

if GRMON=-3 & ((0<comp_mo<=MONTH & comp_yr=YEAR)|0<comp_yr<YEAR) & GRSURV=e3112r9 & e3112r9=maxgrade
then do;
GRMON=maxgrade;
GRAUG=maxgrade;
LOC=11.1;
LOCA=11.1;
end;
if GRMON=-3 & comp_mo=MONTH & comp_yr=YEAR & GRSURV=e3112r9 & maxgrade>0 then do;
GRMON=maxgrade;
GRAUG=maxgrade;
LOC=11.2;
LOCA=11.2;
end;

** If GRSURV is coded with the GRSURV at DLI, (grsurvP) then we must check whether that grade
was completed by Aug of 1999 before coding GRMON=grsurvP.;
if GRSURV=grsurvP then do;
if GRMON~=grsurvP then do;
GRMON=grsurvP;
GRAUG=grsurvP;
LOC=12.1;
LOCA=12.1;
end;
end;
if GRMON=grsurvP then do;
if doicm_LR>MONYR then do;
GRMON=-3;
GRAUG=-3;
chk_grmon=1;
LOC=12.2;
LOCA=12.2;
end;
if grsurvP=maxgrade_LR & comp_yr_LR=YEAR & comp_mo_LR>MONTH then do;
GRMON=-3;
GRAUG=-3;
chk_grmon=2;
LOC=12.3;
LOCA=12.3;
end;
if grsurvP=12 & (cdths>MONYR>0) then do;
GRMON=-3;
GRAUG=-3;
chk_grmon=.;
LOC=12.4;
LOCA=12.4;
end;
end;

** If R received HS Diploma or GED before MONYR of last round, it means that R has completed
high school by that time and so GRMON should reflect the highest grade completed by that time.;
if hsrP>-4|gdrP>-4 then do;
if 0<=grsurvP<=12 & GRMON<grsurvP then do;
subprev=1;
GRMON=grsurvP;
GRAUG=grsurvP;
LOC=13.11;
LOCA=13.11;
end;
end;
if ((0<hsrP<=(MONYR-12))|(0<gdrP<(MONYR-12))) & GRMON<grmonP then do;
if 0<=grmonP<=12 then do;
subprev=1;
GRMON=grmonP;
GRAUG=graugP;
LOC=13.12;
LOCA=13.12;
end;
if grsurvP<0 & grmonP<0 then do;
GRMON=-3;
GRAUG=-3;
LOC=13.13;
LOCA=13.13;
end;
end;

** Here we have put in checks to verify that those who are attending college receive GRMON=-4.;
if ENCAT in (4,5,6,7,9,10,11)|(encatP in (4,5,6,7,9,10,11) & ENCAT=-3) then do;
GRMON=-4;
LOC=13.2;
end;
 

** If R reports a HGC>12 but R is not in a college-degree program we assign the HGC in highschool
as the HGC received.;
if ENCAT in (1,2,3,8,-3) & e3112r9~=-5 then do;
if 12<GRSURV<95|(12<e3112r9<95 & GRSURV=-3) then do;
whyover12=1;
if 0<maxgrade<=12 then do;
GRSURV=maxgrade;
LOCATOR=13.31;
if GRSURV=grsurvP then do;
GRMON=grsurvP;
GRAUG=grsurvP;
LOC=13.31;
LOCA=13.31;
end;
end;
if (12<GRSURV<95 & 0<grsurvP<=12)|(GRSURV<grsurvP & 0<grsurvP<=12) then do;
GRSURV=grsurvP;
GRMON=grsurvP;
GRAUG=grsurvP;
LOCATOR=13.42;
LOC=13.42;
LOCA=13.42;
end;
if (12<GRSURV<95 & 0<grsurvP_no3061<=12)|(GRSURV<grsurvP_no3061 & 0<grsurvP_no3061<=12) then do;
GRSURV=grsurvP_no3061;
GRMON=grsurvP_no3061;
GRAUG=grsurvP_no3061;
LOCATOR=13.5;
LOC=13.5;
LOCA=13.5;
end;
if (12<GRSURV<95 & 0<e3112r9<=12)|(GRSURV<e3112r9 & 0<e3112r9<=12) then do;
GRSURV=e3112r9;
GRMON=-3;
GRAUG=-3;
LOCATOR=13.6;
LOC=13.61;
LOCA=13.61;
if GRSURV=grsurvP then do;
GRMON=grsurvP;
GRAUG=grsurvP;
LOC=13.62;
LOCA=13.62;
end;
if GRSURV=grsurvP_no3061 then do;
GRMON=grsurvP_no3061;
GRAUG=grsurvP_no3061;
LOC=13.63;
LOCA=13.63;
end;
end;
end;
end;
** Hand edit these cases;
if 12<GRSURV<95 & ENCAT in (1,2,3,8,-3) then do;
LOCATOR=13.7;
end;
if 12<GRMON<95 & ENCAT in (1,2,3,8,-3) then do;
LOC=13.7;
end;
if pubid in (1102) then do;
GRSURV=grsurvP;
GRMON=grsurvP;
HE9_GRS=1;
HE9_GRJ=1;
end;

** Hand edits determined using information from all rounds;
if pubid= 7442 then do;
GRSURV=14;
LOCATOR=15;
HE9_GRS=1;
end;
if pubid= 204 then do;
GRSURV=13;
LOCATOR=15;
HE9_GRS=1;
end;
if pubid= 323 then do;
GRSURV=grsurvP;
LOCATOR=15;
HE9_GRS=1;
end;
oldgrs9=GRSURV;
oldgrm9=GRMON;
if pubid in (807 3918 8268 1761 8448 3098 7828 4558 692 8477) then do;
GRSURV=-3;
LOCATOR=15;
HE9_GRS=2;
end;
if pubid= 2217 then do;
GRMON=-3;
LOC=15;
HE9_GRJ=2;
end;
if pubid in (5857 3373 1928 812 7929 7617 3656 27 1948 2142
5579 5995 6182 6345 8802 2217 4923 5447 5782 7607
3270 205 2143 2814 7008 8718 3178 8589 769 6663
7602 8491 8701 8701 8470 8725) then do;
GRSURV=-3;
GRMON=-3;
LOCATOR=15;
LOC=15;
HE9_GRS=2;
HE9_GRJ=2;
end;
if pubid in (8182) then do;
GRSURV=6;
GRMON=6;
LOCATOR=15;
LOC=15;
HE9_GRS=2;
HE9_GRJ=2;
end;
if pubid in (1706) then do;
GRSURV=7;
GRMON=7;
LOCATOR=15;
LOC=15;
HE9_GRS=2;
HE9_GRJ=2;
end;
if pubid in (4864 1428 3438 6645 701 6743 5927) then do;
GRSURV=8;
GRMON=8;
LOCATOR=15;
LOC=15;
HE9_GRS=2;
HE9_GRJ=2;
end;
if pubid in (257 8476 7529 1953) then do;
GRSURV=9;
GRMON=9;
LOCATOR=15;
LOC=15;
HE9_GRS=2;
HE9_GRJ=2;
end;
if pubid in (7349 5499 1260 8733 7848 2590 2590) then do;
GRSURV=10;
GRMON=10;
LOCATOR=15;
LOC=15;
HE9_GRS=2;
HE9_GRJ=2;
end;
if pubid in (6804 7033 6811 8862) then do;
GRSURV=11;
GRMON=11;
LOCATOR=15;
LOC=15;
HE9_GRS=2;
HE9_GRJ=2;
end;
if pubid in (4940 1626) then do;
GRSURV=12;
GRMON=12;
LOCATOR=15;
LOC=15;
HE9_GRS=2;
HE9_GRJ=2;
end;

/**********************/
** Create grsurvF;
if hsrP=-4 & (grsurvFP<12|grsurvFP=95) & (GRSURV<=12|GRSURV=95) then do;
grsurvF=GRSURV;
locF=1;
end;
if hsrP=-4 & (grsurvFP<12|grsurvFP=95) & 12<GRSURV<95 then do;
if (grsurvFP<maxgrade<=12)|(grsurvFP=95 & maxgrade<=12) then do;
grsurvF=maxgrade;
locF=2;
end;
if (maxgrade<=grsurvFP)|maxgrade>12 then do;
grsurvF=grsurvFP;
locF=3;
end;
end;
if hsrP>-4|grsurvFP=12 then do;
grsurvF=grsurvFP;
locF=4;
end;
if hsrP=-4 & grsurvFP<12 & ENCAT in (1,2,3,8,-3) then do;
grsurvF=GRSURV;
locF=5;
end;
if e3112r9=-5 then do;
grsurvF=grsurvFP;
locF=6;
end;

if pubid= 8338 then do;
grsurvF=-3;
locF=15;
end;
if pubid= 6857 then do;
grsurvF=10;
locF=15;
end;

** Create GRAUG;
if HE9_GRJ in (1,2) then do;
GRAUG=GRMON;
LOCA=15;
end;
if grsurvP=12 & GRSURV>=12 & GRAUG~=12 then do;
GRAUG=12;
LOCA=16;
end;
if grsurvP<=12 & GRSURV>=12 & evrloop=0 & (GRAUG=.|GRAUG=-3) & ENCAT in (4,5,6,7,9,10,11) then do;
GRAUG=grsurvP;
LOCA=17;
end;
if 12<grsurvP<95 then do;
GRAUG=graugP;
LOCA=18;
end;
if graugP=12 then do;
GRAUG=12;
LOCA=19;
end;

if LOCATOR~=15 then do;
if attsch=0 & e3878r9~=0 & 0<=e3112r9<=12 & 0<=grsurvP<GRSURV<=12 then do;
GRSURV=grsurvP;
GRAUG=GRSURV;
GRMON=GRSURV;
LOCATOR=20.1;
LOC=20.1;
LOCA=20.1;
if locF in (1,5) then do;
grsurvF=GRSURV;
locF=7;
end;
end;
if attsch=0 & e3878r9~=0 & 12<e3112r9<95 & 0<=grsurvP_no3061<GRAUG<=12 & grmonP=-4 then do;
GRAUG=grsurvP_no3061;
LOCA=20.2;
end;
end;

if pubid in (2848) then do;
GRAUG=12;
LOCA=15;
end;

if (ENCAT in (4,5,6,7,9,10,11)|(encatP in (4,5,6,7,9,10,11) & ENCAT=-3)) then do;
GRMON=-4;
end;

********************************************************************************************************
*** [IV] CREATED VARIABLE - HIGHEST DEGREE RECEIVED AS OF THE SURVEY DATE (DEGSURV) ***
********************************************************************************************************;
DEGSURV=0;

** GED;
if GED=1 then DEGSURV=1;
if GED=-3 then DEGSURV=-3;

** High School Diploma;
if HSD=1 then DEGSURV=2;
if HSD=-3 then DEGSURV=-3;

** Junior College or two-year Associate Degree;
if CDTAA>-4 then DEGSURV=3;

** Bachelor's Degree;
if CDTBA>-4 then DEGSURV=4;

** Master's Degree;
if CDTMA>-4 then DEGSURV=5;

** Doctoral Degree;
if CDTDC>-4 then DEGSURV=6;

** Professional Degree;
if CDTPF>-4 then DEGSURV=7;

** If degree received cannot determine what degree received;
do i=1 to dim(e23450);
if e23450(i) in (-1, -2, -3) then DEGSURV=-3;
end;

** Check these cases as they should not occur;
if 0<=DEGSURV<degsurvP then prev_deg=1;

** Not sure whether received a H.S. Diploma or not;
if pubid in (101 510 3098 4433 4999 7725 7929 3793 4682 7179
8873 205 8114 8088 19 65 2810) & DEGSURV=2 then do;
DEGSURV=-3;
HE9_DG=1;
end;
** Not sure whether received an AA or BA.;
if pubid in (311 5151 5620) then do;
DEGSURV=-3;
HE9_DG=1;
end;
** Not sure whether received a GED, a H.S.Diploma, both or none.;
if pubid= 7391 & DEGSURV=1 then do;
DEGSURV=-3;
HE9_DG=1;
end;

********************************************************************************************************
*** [V] CREATED VARIABLE - HIGHEST DEGREE COMPLETED AS OF JUNE 30, 2001 (DEGAUG) ***
********************************************************************************************************;
DEGAUG=0;
** GED;
if 0<CDTGD<=MONYR then DEGAUG=1;
if CDTGD in (-3, -2, -1) then DEGAUG=-3;

** High School Diploma;
if 0<CDTHS<=MONYR then DEGAUG=2;
if CDTHS in (-3, -2, -1) then DEGAUG=-3;

** Junior College or 2-year Associate Degree;
if 0<CDTAA<=MONYR then DEGAUG=3;
if CDTAA in (-3, -2, -1) then DEGAUG=-3;

** Bachelor's Degree;
if 0<CDTBA<=MONYR then DEGAUG=4;
if CDTBA in (-3, -2, -1) then DEGAUG=-3;

** Master's Degree;
if 0<CDTMA<=MONYR then DEGAUG=5;
if CDTMA in (-3, -2, -1) then DEGAUG=-3;

** Doctoral Degree;
if 0<CDTDC<=MONYR then DEGAUG=6;
if CDTDC in (-3, -2, -1) then DEGAUG=-3;

** Professional Degree;
if 0<CDTPF<=MONYR then DEGAUG=7;
if CDTPF in (-3, -2, -1) then DEGAUG=-3;

if DEGSURV=-3 then DEGAUG=-3;

** Making sure that those with invalid date of degree received dates also have invalid codes for
DEGAUG. However for those who received the degree by last interview, even if we do not know
those dates must be coded as having received that degree by MONTH of this round. Also, constrain
the highest degree received by MONTH of this round to the highest degree received by the
interview date of this round.;
if (DEGSURV=1 & -4<CDTGD<=0)|(DEGSURV=2 & -4<CDTHS<=0)|(DEGSURV=3 & -4<CDTAA<=0)
|(DEGSURV=4 & -4<CDTBA<=0)|(DEGSURV=5 & -4<CDTMA<=0)|(DEGSURV=6 & -4<CDTDC<=0)
|(DEGSURV=7 & -4<CDTPF<=0) then do;
datedeg=1;
DEGAUG=-3;
end;
** Constrain DEGAUG by prevdegsruv if the latter is equal to DEGSURV in this round;
if DEGAUG~=DEGSURV & DEGSURV=degsurvP & DEGSURV>=0 & DEGAUG>0 then do;
DEGAUG=degsurvP;
end;
if DEGAUG=-3 & DEGSURV=degsurvP & DEGSURV>=0 & 0<dlicm<MONYR then do;
DEGAUG=degsurvP;
end;

if ENCAT in (-1,-2) then ENCAT=-3;
if GRSURV in (-1,-2) then GRSURV=-3;
if GRMON in (-1,-2) then GRMON=-3;
if DEGSURV in (-1,-2) then DEGSURV=-3;
if DEGAUG in (-1,-2) then DEGAUG=-3;

if e3112r9=-5 then do;
ENROLL=-5;
ENCAT=-5;
GRSURV=-5;
GRMON=-5;
GRAUG=-5;
DEGSURV=-5;
DEGAUG=-5;
GED=-5;
HSD=-5;
LOCATOR=-5;
LOC=-5;
LOCA=-5;
end;

chk1=.; chk2=.; chk3=.; chk4=.; chk4z=.; chk5=.; chk6=.;

if ENCAT in (4,5,6,7,9,10,11) then do;
if 0<=grsurv<12 then chk1=1;
if grsurv=95 then chk1=2;
end;

if ENCAT in (1,2,3,8) then do;
if 12<grsurv<95 then chk2=1;
if grsurv=95 then chk2=2;
end;

if degsurv=0 & ENCAT in (2,3,4,5,6,7,9,10,11) then chk3=1;
if degsurv=1 & ENCAT in (1,8,3,5,6,7) then chk3=2;
if degsurv=2 & ENCAT in (1,8,2,5,6,7) then chk3=3;
if degsurv=3 & ENCAT in (1,8,2,3,6,7) then chk3=4;
if degsurv=4 & ENCAT in (1,8,2,3,5,7) then chk3=5;
if degsurv in (5,6,7) & ENCAT in (1,8,2,3,5,6) then chk3=6;

if 0<=e2857r9<grsurv<95 then do;
if 0<=e2857r9<grsurvP<95 & e3878r9~=0 then chk4=1.1;
if 0<=e2857r9<maxgrade<95 then chk4=1.2;
if 0<=e2857r9<e3112r9<95 then chk4=1.3;
if hsd=1 & grsurv=12 then chk4=.;
end;
if 0<=e2857r9<6 & ENCAT in (4,5,6,7,9,10,11) then z=e2857r9+12;
if z=. then chk4z=chk4;
if 0<=z<grsurv then do;
if 0<=z<grsurvP & e3878r9~=0 then chk4z=1.1;
if 0<=z<maxgrade then chk4z=1.2;
if 0<=z<e3112r9 then chk4z=1.3;
if hsd=1 & grsurv=12 then chk4z=.;
end;

if ENCAT=-3 & grsurv~=-3 then chk5=1;
if ENCAT~=-3 & grsurv=-3 & LOCATOR~=15 then chk5=2;
if ENCAT in (4,5,6,7,9,10,11) & currcoll=0 & 0<=grsurvP<grsurv & ever_24yrinst~=1 then chk6=1;

if (hsr6>-4|hsr5>-4|hsr4>-4|hsr3>-4|hsr2>-4) & CDTHS=-4 then chk7=1;
if (gdr6>-4|gdr5>-4|gdr4>-4|gdr3>-4|gdr2>-4) & CDTGD=-4 then chk8=1;

if comp_mo>0 & comp_yr>0 then comp_cms=((comp_yr-1980)*12)+comp_mo;

*** COMPUTE grmonr1;
** Compute grmonr1 using information in this round (grade loops);
if grmonr1=-16 then do;
** Select cases where there is a valid grade and it is greater than the previously recorded grade;
do i=1 to dim(gratnd);
if gratnd(i)>=0 & gratnd(i)>grmonr1 then do;
if grcomp(i)=1 then do;
if (0<yrcomp(i)<1997)|(yrcomp(i)=1997 & 0<mocomp(i)<=MONTH) then do;
if locR1~=. then do;
grmonr1x=grmonr1;
locR1x=locR1;
end;
cjumonr1=mocomp(i);
cjuyrr1=yrcomp(i);
grmonr1=gratnd(i);
locR1=1.1;
end;
end;
end;
end;
** If same grade is reported more than once.;
do i=1 to dim(gratnd);
if gratnd(i)>=0 & gratnd(i)=grmonr1 & grcomp(i)=1
& ((0<yrcomp(i)<1997)|(yrcomp(i)=1997 & 0<mocomp(i)<=MONTH)) then do;
if cjuyrr1>0 & cjumonr1<0 & mocomp(i)>0 & cjuyrr1=yrcomp(i) then do;
if locR1~=. then do; grmonr1x=grmonr1; locR1x=locR1; end;
cjumonr1=mocomp(i);
cjuyrr1=yrcomp(i);
grmonr1=gratnd(i);
locR1=1.2;
end;
if cjuyrr1<0 & mocomp(i)>0 then do;
if locR1~=. then do; grmonr1x=grmonr1; locR1x=locR1; end;
cjumonr1=mocomp(i);
cjuyrr1=yrcomp(i);
grmonr1=gratnd(i);
locR1=1.3;
end;
if cjuyrr1>0 & cjumonr1>0 & mocomp(i)>0 & (cjuyrr1~=yrcomp(i)|cjumonr1~=mocomp(i)) then do;
if yrcomp(i)>cjuyrr1 then do;
if locR1~=. then do; grmonr1x=grmonr1; locR1x=locR1; end;
cjumonr1=mocomp(i);
cjuyrr1=yrcomp(i);
grmonr1=gratnd(i);
locR1=1.4;
end;
if yrcomp(i)=cjuyrr1 & mocomp(i)>cjumonr1 then do;
if locR1~=. then do; grmonr1x=grmonr1; locR1x=locR1; end;
cjumonr1=mocomp(i);
cjuyrr1=yrcomp(i);
grmonr1=gratnd(i);
locR1=1.5;
end;
end;
end;
end;
if locR1=1.1 then do;
if intmr1=cjumonr1 & intyr1=cjuyrr1 & grmonr1=0 & grsurvr1>0 then do;
grmonr1=grsurvr1;
locR1=1.6;
end;
if intmr1=cjumonr1 & intyr1=cjuyrr1 & grmonr1=grsurvr1-1 & grsurvr1=GRMON-1 & grmonr1>0 then do;
grmonr1=grsurvr1;
locR1=1.7;
end;
if intmr1=cjumonr1 & intyr1=cjuyrr1 & grmonr1>0 & grsurvr1=0 then do;
grsurvr1=grmonr1;
locatorR1=2;
end;
if intyr1=cjuyrr1 & intyr1=1997 & 0<intmr1<=cjumonr1 & grsurvr1=e5000r1 & e5000r1>0
& e3061r9=e5000r1+1 & grmonr1=e3061r9+1 & grmonr1<=GRMON then do;
grmonr1=e3061r9;
locR1=1.8;
end;
if intyr1=cjuyrr1 & intyr1=1997 & 0<intmr1<=cjumonr1 & grsurvr1=e5000r1 & e5000r1>0
& e3061r9=e5000r1+2 & grmonr1=e3061r9 & grmonr1<=GRMON then do;
grsurvr1=e5000r1+1;
locatorR1=3;
end;
if intyr1=cjuyrr1 & intyr1=1997 & 0<intmr1<=cjumonr1 & grsurvr1=e5000r1 & e5000r1>0 & e3061r9=-4
& e3112r9=e5000r1+2 & grmonr1=GRMON & GRMON=e3112r9 & e3500r1=e5000r1+1 & e2857r9=e3112r9+1 then do;
grsurvr1=e5000r1+1;
locatorR1=4;
end;
end;
end;

if grmonr1=-16 & MAXGRADE-1=grsurvr1 & MAXGRADE>0 & grsurvr1>0 & doicmr1<213 & DOICM>212 then do;
if comp_yr>1997|(comp_mo>MONTH & comp_yr=1997) then do;
if locR1~=. then do; grmonr1x=grmonr1; locR1x=locR1; end;
grmonr1=grsurvr1;
locR1=2;
end;
end;

if grmonr1=-16 then do;
if doicmr1<213 & DOICM>212 & grsurvr1=GRSURV & grsurvr1>0 then do;
if locR1~=. then do; grmonr1x=grmonr1; locR1x=locR1; end;
grmonr1=grsurvr1;
locR1=3.1;
end;
if doicmr1>212 then do;
if locR1~=. then do; grmonr1x=grmonr1; locR1x=locR1; end;
grmonr1=grsurvr1;
locR1=4;
end;
end;

if encatr1 in (4,5,6,7,9,10,11) then do;
if locR1~=. then do; grmonr1x=grmonr1; locR1x=locR1; end;
grmonr1=-4;
locR1=6;
end;

if grsurvF=grsurvFP & grsurvFP>grsurvFr1>0 & locatorR1~=. & e3112r2=-5 & e3112r3=-5 & e3112r4=-5
& e3112r5=-5 & e3112r6=-5 & e3112r7=-5 & e3112r8=-5 then do;
grsurvFP=grsurvFr1;
grsurvF=grsurvFr1;
locF=8;
end;

if grsurvF>GRSURV>=0 then do;
checkthese=1;
if grsurvr8~=-5 & (0<GRSURV<=grsurvr8) then checkthese=0;
if grsurvr8=-5 & grsurvr7~=-5 & (0<GRSURV<=grsurvr7) then checkthese=0;
if grsurvr8=-5 & grsurvr7=-5 & grsurvr6~=-5 & (0<GRSURV<=grsurvr6) then checkthese=0;
if grsurvr8=-5 & grsurvr7=-5 & grsurvr6=-5 & grsurvr5~=-5 & (0<GRSURV<=grsurvr5) then checkthese=0;
if grsurvr8=-5 & grsurvr7=-5 & grsurvr6=-5 & grsurvr5=-5 & grsurvr4~=-5 & (0<GRSURV<=grsurvr4) then checkthese=0;
if grsurvr8=-5 & grsurvr7=-5 & grsurvr6=-5 & grsurvr5=-5 & grsurvr4=-4 & grsurvr3~=-5 & (0<GRSURV<=grsurvr3) then checkthese=0;
if grsurvr8=-5 & grsurvr7=-5 & grsurvr6=-5 & grsurvr5=-5 & grsurvr4=-4 & grsurvr3=-5 & grsurvr2~=-5 & (0<GRSURV<=grsurvr2) then checkthese=0;
if grsurvr8=-5 & grsurvr7=-5 & grsurvr6=-5 & grsurvr5=-5 & grsurvr4=-5 & grsurvr3=-5 & grsurvr2=-5 & (0<GRSURV<=grsurvr1) then checkthese=0;
end;
if grsurvFr1>grmonr1>=0 then checkthese=2;
if grsurvr1>GRSURV>=0 then checkthese=3;
if grmonr1>GRMON>=0 then checkthese=4;

ENDSAS;
 

Return to top


Current or Most Recent School Private or Parochial

Variables Created:  CV_SCHOOL_TYPE (SLTYPE)

Variables Used

Name in Program

Question Name in Data

 

Name in Program

Question Name in Data

TYPER1 CV_SCHOOL_TYPE_1997   SSTOP1Y2 NEWSCHOOL_STOP1.02~Y
TYPER2 CV_SCHOOL_TYPE_1998   SSTOP1M3 NEWSCHOOL_STOP1.03~M
TYPER3 CV_SCHOOL_TYPE_1999   SSTOP1Y3 NEWSCHOOL_STOP1.03~Y
TYPER4 CV_SCHOOL_TYPE_2000   SSTOP1M4 NEWSCHOOL_STOP1.04~M
TYPER5 CV_SCHOOL_TYPE_2001   SSTOP1Y4 NEWSCHOOL_STOP1.04~Y
TYPER6 CV_SCHOOL_TYPE_2002   SSTOP2M1 NEWSCHOOL_STOP2.01~M
TYPER7 CV_SCHOOL_TYPE_2003   SSTOP2Y1 NEWSCHOOL_STOP2.01~Y
TYPER8 CV_SCHOOL_TYPE_2004   SSTOP2M2 NEWSCHOOL_STOP2.02~M
SPERIOD1-4 NEWSCHOOL_PERIODS.01-.04   SSTOP2Y2 NEWSCHOOL_STOP2.02~Y
SCODE1-4 NEWSCHOOL_SCHCODE.01-.04   SSTOP3M1 NEWSCHOOL_STOP3.01~M
SSTOP1M1 NEWSCHOOL_STOP1.01~M   SSTOP3Y1 NEWSCHOOL_STOP3.01~Y
SSTOP1Y1 NEWSCHOOL_STOP1.01~Y   STYPE1-3 NEWSCHOOL_TYPE.01-.03
SSTOP1M2 NEWSCHOOL_STOP1.02~M   pubid PUBID

Codes for Created Variable

1 = Public school
2 = Private, not parochial 
3 = Parochial
4 = Other

This program is used to create the school type variables from Round 9, i.e. the current or most recent schools that the youth attended are public, private, parochial or other. This is completed in the following steps:

1) We first decide which school is the most recent school (non-college) that the youth participated by the ending date for different enrollment periods.
2) We can get the school type from the new school roster. However, in the program, these two steps can not be separated.


/* create the array variables.*/

* # of enrollment periods;
array speriod speriod1-speriod4;

* ending date for each period;
array sstop1m sstop1m1-sstop1m4;
array sstop1y sstop1y1-sstop1y4;
array sstop2m sstop2m1-sstop2m2;
array sstop2y sstop2y1-sstop2y2;
array sstop3m sstop3m1 sstop3m2;
array sstop3y sstop3y1 sstop3y2;

* school code, i.e. elementary school, high school or college;
array scode scode1-scode4;

*school type for round 8;
array stype stype1-stype4;

* ending time for each school;
array srecm srecm1-srecm4;
array srecy srecy1-srecy4;

* school length counting both month&year: the month length from Jan. 1990 to the ending month for each school;
array mlength mlength1-mlength4;

* school length counting only year: the year length from 1990 to the ending year for each school;
* this variable is to take care of the situation where ending year is invalid;
array ylength ylength1-ylength4;

/************************* step 1).In the process to decide the most recent school. ************************/
do i=1 to 4;
srecm[i]=-4;
srecy[i]=-4;
if speriod[i]=1 and scode[i] in (1,2,3) then do;
srecm[i]=sstop1m[i];
srecy[i]=sstop1y[i];
end;
if speriod[i]=2 and scode[i] in (1,2,3) then do;
srecm[i]=sstop2m[i];
srecy[i]=sstop2y[i];
end;
if speriod[i]=3 and scode[i] in (1,2,3) then do;
srecm[i]=sstop3m[i];
srecy[i]=sstop3y[i];
end;
if srecm[i] gt 0 and srecy[i] gt 0 then mlength[i]=12*(srecy[i]-1990)+srecm[i];
else mlength[i]=-4;
if srecy[i] gt 0 then ylength[i]=srecy[i]-1990;
else ylength[i]=-4;
end;

maxmleng=max(mlength1,mlength2, mlength3, mlength4);
if stype1=-5 then maxmleng=-5;

maxyleng=max(ylength1,ylength2, ylength3, ylength4);
if stype1=-5 then maxyleng=-5;

/************** step 2). Decide the latest non-college school and its type*************/
type1=-4;

***** create the flag variables;
* flag the cases where multiple schools' ending year/month are same as "maxmleng";
maxmeq=0;
do i=1 to 4;
if maxmleng>0 and mlength[i]=maxmleng then maxmeq=maxmeq+1;
end;

* flag the cases where multiple schools' ending year are the same as "maxyleng" and ending months are invalid answer;
invalidm=0; maxyeq=0;
do i=1 to 4;
if maxyleng>0 and ylength[i]=maxyleng and srecm[i] in (-1,-2,-3) then invalidm=invalidm+1;
if maxyleng>0 and ylength[i]=maxyleng then maxyeq=maxyeq+1;
end;

***** first step to create school type;
* use only the year information first;
do i=1 to 4;
if maxyleng>0 and ylength[i]=maxyleng then type1=stype[i];
end;

* then use the month information to make it more precise;
do i=1 to 4;
if maxmleng>0 and mlength[i]=maxmleng then type1=stype[i];
end;

***** Fix the special cases where multiple schools' ending years are same as maxyleng;
/* go back to fix the case such as 97.12 and 99.-2. because if "maxmleng" cover "maxyleng", the codes above
will pick up the school ending on 97.12 as most recent school.*/
if maxyeq=1 then do;
do i=1 to 4;
if ylength[i]=maxyleng then type1=stype[i];
end;
end;

if invalidm ge 2 then type1=-3;

* flag the cases which has 98.02 and 98.-3;
flag=0;
if maxyeq ge 2 and invalidm ge 1 then flag=1;

if flag=1 then type1=-3;

* fix the case such as 99.12, 99.-2 99.-3 or 2000.12 2000.-2;
if maxyeq ge 2 then do;
do i=1 to 4;
if ylength[i]=maxyleng and srecm[i]=12 then do;
type1=stype[i];
flag2=1;
end;
end;
end;

***** Fix the special cases where multiple schools ending year/months are same as maxmleng;
/*This loop assigns value of PUBLIC schools (1) to TYPE1 in cases where one reported school type=public
and one reported school type="other". In cases where one reported school type=PRIVATE and one reported
type="other", value for PRIVATE school type is assigned. Cases where one school type=PUBLIC and another
school type=PRIVATE are flagged and looked into. */

*dummy for one school is public school and the other is religious school;
pubrelg=0;
*dummy for one school is public school and the other is private school;
pubpriv=0;
*dummy for one school is private and the other is religious school;
privrelg=0;

if maxmeq ge 2 then do;
do i=1 to 4;
if mlength(i)=maxmleng and stype(i)^=type1 then do;
if stype(i) in (6,9,10,11,-1,-2,-3) and type1 in (1,2,12,13) then type1=type1;
if stype(i) in (1,2,12,13) and type1 in (6,9,10,11,-1,-2,-3) then type1=stype[i];
if stype(i) in (6,9,10,11,-1,-2,-3) and type1 in (3,4) then type1=type1;
if stype(i) in (3,4) and type1 in (6,9,10,11,-1,-2,-3) then type1=stype[i];
if stype(i) in (6,9,10,11,-1,-2,-3) and type1=5 then type1=5;
if stype(i)=5 and type1 in (6,9,10,11,-1,-2,-3) then type1=5;
if (stype(i) in (1,2,12,13) and type1 in (3,4)) or
(stype(i) in (3,4) and type1 in (1,2,12,13)) then pubrelg=1;
if (stype(i) in (1,2,12,13) and type1=5) or
(stype(i)=5 and type1 in (1,2,12,13)) then pubpriv=1;
if (stype(i)=5 and type1 in (3,4)) or
(stype(i) in (3,4) and type1=5) then privrelg=1;
end;
end;
end;

***** Invalid answers;
* for the invalid answers;
if scode1 in (-1,-2,-3)
or scode2 in (-1,-2,-3)
or scode3 in (-1,-2,-3)
or scode4 in (-1,-2,-3)
then type1=-3;

if (scode1 in (1,2,3) and srecy1 in (-1,-2,-3))
or (scode2 in (1,2,3) and srecy2 in (-1,-2,-3))
or (scode3 in (1,2,3) and srecy3 in (-1,-2,-3))
or (scode4 in (1,2,3) and srecy4 in (-1,-2,-3))
then type1=-3;

* if the respondent only goes to one school in r9,input that school type;
if scode1 in (1,2,3)
and scode2 in (-4, 4, 5)
and scode3 in (-4, 4, 5)
and scode4 in (-4, 4, 5)
then type1=stype1;

/******************************* recode the type variable.*************************************/
sltype=-4;
if type1 in (1,2,12,13) then sltype=1;
if type1=5 then sltype=2;
if type1 in (3,4) then sltype=3;
if type1 in (6,9,10,11) then sltype=4;
if -4<type1<0 then sltype=-3;
if stype1=-5 then sltype=-5;

* Hand edit other cases who got "-3" because of stopping date but have same school type for all valid schools
or the most recent school is detectable from the other information such as interview date;
flag1=0;
flag2=0;
if sltype=-3 and stype1=stype2 and stype1>0 then flag1=1;
if flag1=1 then sltype=1;
if int_y=-5 then sltype=-5;

endsas;


Return to top


Date Received Diploma or Degree

Variables Created: 

 Variables Used

Name in Program Question Name in Data   Name in Program Question Name in Data   Name in Program Question Name in Data

Round 1:

 

 

Round 4 con't:

 

 

Round 7 con't:

 

gdr1

CV_GED

 

stopyr4_22

NEWSCHOOL_STOP2.02~Y

 

stopmr7_22

NEWSCHOOL_STOP2.02~M

hsr1

CV_HS_DIPLOMA

 

stopmr4_23

NEWSCHOOL_STOP2.03~M

 

stopyr7_22

NEWSCHOOL_STOP2.02~Y

Doicmr1

CV_INTERVIEW_CMONTH

 

stopyr4_23

NEWSCHOOL_STOP2.03~Y

 

stopmr7_31

NEWSCHOOL_STOP3.01~M

intdr1

CV_INTERVIEW_DATE~D

 

scoder4_1-_5

NEWSCHOOL_SCHCODE.01-.05

 

stopyr7_31

NEWSCHOOL_STOP3.01~Y

intmr1

CV_INTERVIEW_DATE~M

 

lftsc2r4_1, _2

NEWSCHOOL_LEFT2.01, .02

 

e21300r7_101-_109

YSCH-213001.01-.09

intyr1

CV_INTERVIEW_DATE~Y

 

e21300r4_101-_108

YSCH-21300.01.01-.08

 

e21300r7_201-_209

YSCH-21300.02.01-.09

e21300r1_101-_102

YSCH-21300.01.01-.02

 

e21300r4_201-_206

YSCH-21300.02.01-.06

 

e21300r7_301-_303

YSCH-21300.03.01-.03

e21400r1_101-_102

YSCH-21400.01.01-.02

 

e21300r4_301, _302

YSCH-21300.03.01, .02

 

e21300r7_401

YSCH-21300.04.01

 

 

 

e21300r4_401, _402

YSCH-21300.04.01, .02

 

e21300r7_501

YSCH-21300.05.01

Round 2:

 

 

e21400r4_101-_108

YSCH-21400.01.01-.08

 

e21400r7_101-_109

YSCH-21400.01.01-.09

gdr2

CV_GED

 

e21400r4_201-_206

YSCH-21400.02.01-.06

 

e21400r7_201-_209

YSCH-21400.02.01-.09

hsr2

CV_HS_DIPLOMA

 

e21400r4_301, _302

YSCH-21400.03.01, .02

 

e21400r7_301-_303

YSCH-21400.03.01-.03

doicmr2

CV_INTERVIEW_CMONTH

 

e21400r4_401, _402

YSCH-21400.04.01, .02

 

e21400r7_401

YSCH-21400.04.01

intdr2

CV_INTERVIEW_DATE~D

 

schidr4_1-_5

NEWSCHOOL_PUBID.01-.05

 

schidr7_1-_5

NEWSCHOOL_PUBID.01-.05

intmr2

CV_INTERVIEW_DATE~M

 

 

 

 

 

 

intyr2

CV_INTERVIEW_DATE~Y

 

Round 5:

 

 

Round 8:

 

e27337r2_1-_5

YSCH-27337.01-.05

 

gdr5

CV_GED