Appendix 3: Family Background and Formation Variable Creation

Return to Table of Contents


Household Size as of the Survey Date

Variables Created:

1. Household size = HHSIZE = CV_HH_SIZE
2. Number of household members less than 6 years old = UNDER6 = CV_HH_UNDER_6
3. Number of household members less than 18 years old = UNDER18 = CV_HH_UNDER_18CV_HH_SIZE

Variables Used

Variable Name in Program

Question in Survey

pubid

PUBID
HAGE01 HHI AGE (ROS ITEM) L1 2003

HAGE02

HHI AGE (ROS ITEM) L2 2003

HAGE03

HHI AGE (ROS ITEM) L3 2003

HAGE04

HHI AGE (ROS ITEM) L4 2003

HAGE05 HHI AGE (ROS ITEM) L5 2003
HAGE06 HHI AGE (ROS ITEM) L6 2003
HAGE07 HHI AGE (ROS ITEM) L7 2003
HAGE08 HHI AGE (ROS ITEM) L8 2003
HAGE09 HHI AGE (ROS ITEM) L9 2003
HAGE10 HHI AGE (ROS ITEM) L10 2003
HAGE11 HHI AGE (ROS ITEM) L11 2003
HAGE12 HHI AGE (ROS ITEM) L12 2003
HAGE13 HHI AGE (ROS ITEM) L13 2003
HAGEST01 HHI, ESTIMATED AGE OF HH MEMBER 01 AS OF INTDATE (ROS ITEM) 2003
HAGEST02 HHI, ESTIMATED AGE OF HH MEMBER 02 AS OF INTDATE (ROS ITEM) 2003
HAGEST03 HHI, ESTIMATED AGE OF HH MEMBER 03 AS OF INTDATE (ROS ITEM) 2003
HAGEST04 HHI, ESTIMATED AGE OF HH MEMBER 04 AS OF INTDATE (ROS ITEM) 2003
HAGEST05 HHI, ESTIMATED AGE OF HH MEMBER 05 AS OF INTDATE (ROS ITEM) 2003
HAGEST06 HHI, ESTIMATED AGE OF HH MEMBER 06 AS OF INTDATE (ROS ITEM) 2003
HUID01 HHI UID (ROS ITEM) L12003
HUID02 HHI UID (ROS ITEM) L22003
HUID03 HHI UID (ROS ITEM) L32003
HUID04 HHI UID (ROS ITEM) L42003
HUID05 HHI UID (ROS ITEM) L52003
HUID06 HHI UID (ROS ITEM) L62003
HUID07 HHI UID (ROS ITEM) L72003
HUID08 HHI UID (ROS ITEM) L82003
HUID09 HHI UID (ROS ITEM) L92003
HUID10 HHI UID (ROS ITEM) L102003
HUID11 HHI UID (ROS ITEM) L112003
HUID12  HHI UID (ROS ITEM) L122003
HUID13  HHI UID (ROS ITEM) L132003
RSAGE SYMBOL!KEY!AGE

This program creates several variables describing the composition of the respondent's household: the total number of residents, the number of residents under age 6, and the number of residents under age 18.


ARRAY HAGE HAGE01-HAGE13;
ARRAY HUID HUID01-HUID13;
ARRAY HAGEST HAGEST01-HAGEST13;

/* Create dummy variables HHDUM[I] (I=1 TO 13) that equal one if the ith member has a member ID, and zero
if the ith member does not have a member ID (i.e.HHID0i=-4).Also create dummies for the age:DUM6[I] (I=1 TO 13)
that equal 1 if the ith household member is under age 6 and DUM18[I] (I=1 TO 13) that equal 1 if the ith
household member is under age 18.*/

ARRAY HHDUM HHDUM01-HHDUM13;
ARRAY DUM6 DUM601-DUM613;
ARRAY DUM18 DUM1801-DUM1813;

DO I=1 TO 13;
HHDUM[I]=0;
DUM6[I]=0;
DUM18[I]=0;
END;

DO I=1 TO 13;
IF HUID[I]>-1 THEN HHDUM[I]=1;
IF -1<HAGE[I]<6 THEN DUM6[I]=1;
IF -1<HAGE[I]<18 THEN DUM18[I]=1;
IF -4<HAGE[I]<0 AND HAGEST[I]=1 THEN DO;
DUM18[I]=1;
UND6=-3;
END;
IF -4<HAGE[I]<0 AND HAGEST[I]=2 THEN DUM18[I]=1;
END;

/* Create the dummy for the respondent's age RDUM6 AND RDUM18. */
RDUM6=0;
RDUM18=0;

IF -1<RSAGE<6 THEN RDUM6=1;
IF -1<RSAGE<18 THEN RDUM18=1;


/* Create household size HHSIZE by adding up the dummies HHDUM[I] and also add one due to the respondent himself.
Similarly, create variabes UNDER6 AND UNDER18 by adding up the other two dummies.*/

HHSIZE=1;
UNDER6=RDUM6;
UNDER18=RDUM18;

DO I=1 TO 13;
HHSIZE=HHSIZE+HHDUM[I];
UNDER6=UNDER6+DUM6[I];
UNDER18=UNDER18+DUM18[I];
END;

IF HUID01=-5 THEN HHSIZE=-5;
do I=1 TO 13;
IF -4<HUID[I]<0 THEN HHSIZE=-3;
END;

IF HUID01=-5 THEN UNDER6=-5;
IF HUID01=-5 THEN UNDER18=-5;
DO I=1 TO 13;
IF -4<HAGE[I]<0 THEN PRT1=-3;
END;

Do I=1 TO 13;
IF -4<HAGEST[I]<0 AND PRT1=-3 THEN PRT2=-3;
END;

IF PRT2=-3 OR HHSIZE=-3 THEN DO;
UNDER6=-3;
UNDER18=-3;
END;
IF UND6=-3 THEN DO;
UNDER6=-3;
END;

ENDSAS;

 

Return to top


Youth's Relationship to Household Parent Figure(s)

Variable Created: CV_YTH_REL_HH_CURRENT: Relationship of the parent figure(s)/guardian(s) in household to the youth as of the survey date.

Variables Used

Name in Program

Question Name

Name in program

Question Name

Round 1:   Round 7:  
HH1UID01-17 HHI2_UID.01-.17 hhage01-13 HHI_AGE.01-.13
SH931-5 SH93.01-.05 hhest_01-06 HHI_AGEEST.01-.06
YID YOUTH_ID.01  marry_1-13 HHI_MARSTAT.01-.13
REL_r1  CV_YTH_REL_HH_CURRENT hhrel_1-13 HHI_RELY.01-.13
    HHUID01-13 HHI_UID.01-.13
Rounds 2-6:   age SYMBOL!KEY!AGE
REL_r2  CV_YTH_REL_HH_CURRENT  pubid PUBID
REL_r3  CV_YTH_REL_HH_CURRENT    
REL_r4  CV_YTH_REL_HH_CURRENT    
REL_r5  CV_YTH_REL_HH_CURRENT    
REL_r6  CV_YTH_REL_HH_CURRENT    

 Codes for Created Variable

-5 = Non-Interview

6 = Adoptive parent(s)

1 = Both biological parents 7 = Foster parent(s)
2 = Two parents, biological mother 8 = No parents, grandparents
3 = Two parents, biological father 9 = No parents, other relatives
4 = Biological mother only 10 = Anything else
5 = Biological father only  

NOTE: In some cases Rs did not report a relationship code for one or more household members (coded as -3). In such cases, if a parent/parent figure was reported in the household, the R received the correct code for that relationship. If no parent figure was reported and R is over 18, R  received a code of "10" on the CV. If no parent figure was reported and R is under 18, R received a code of "-3" on the CV.*/

This program creates a variable identifying the youth's relationship to the primary adults in the household. In rounds 2-7 there was no information collected on the legal guardian of the youth, so it is not possible to determine whether respondents are living with non-parent relatives because they are guardians or because the living situation is better (e.g., closer to school, no rent).  For this reason, youths above the age 18 and above are considered independent and, if they are not living with an identified parent or parent-figure (legal guardian), are put into the anything else category. Youths below the age of 18 who are not living with an identified parent or parent-figure are put into the category that most closely matches their household situation.


if hhrel_01~=-5;

array hhrel (*) hhrel_01-hhrel_13;
array hhmst (*) hhmst_01-hhmst_13;
array hhage (*) hhage_01-hhage_13;
array hhuid (*) hhuid_01-hhuid_13;
array hhest (*) hhest_01-hhest_06;
array hhuid1 (*) hhuid1_01-hhuid1_17;


** Wrong input information;
if PUBID=406 then do;
do i=1 to 5;
hhrel(i)=68;
end;
do i=6 to 13;
hhrel(i)=-4;
end;
do i=1 to 5;
hhmst(i)=0;
end;
do i=6 to 13;
hhmst(i)=-4;
end;
hhage_01=21;
hhage_02=22;
hhage_03=20;
hhage_04=21;
hhage_05=18;
do i=6 to 13;
hhage(i)=-4;
end;
do i=1 to 5;
hhuid(i)=200300+i;
end;
do i=6 to 13;
hhuid(i)=-4;
end;
handedit=1;
end;



** Set age of Household members using estimated age when actual age is not known.;
do i=1 to 6;
* Set age of household member to 25 when estimated his/her age is over 25 (estimated age = 4, 5, 6);
if hhest(i)>3 then hhage(i)=25;
* Set age of household member to 17 when estimated his/her age is under 18 (estimated age = 1, 2);
if hhest(i) in (1,2) then hhage(i)=17;
end;

** This part identifies legal guardians so that we can determine whether any guardians are present from
the Round 1 interview using only unique IDs. IDs of Household members after Round 1 have 6 digits, so
this program will not identify any household member from any round other than Round 1 as the legal
guardian. This is necessary as we don't have information on legal guardian status for Household
members after Round 1.;

do i=1 to 17;
if yid=1 & sh93_01>0 & sh93_01+100=hhuid1(i) then uid=hhuid1(i);
if yid=2 & sh93_02>0 & sh93_02+100=hhuid1(i) then uid=hhuid1(i);
if yid=3 & sh93_03>0 & sh93_03+100=hhuid1(i) then uid=hhuid1(i);
if yid=4 & sh93_04>0 & sh93_04+100=hhuid1(i) then uid=hhuid1(i);
if yid=5 & sh93_05>0 & sh93_05+100=hhuid1(i) then uid=hhuid1(i);
end;

** Household member identified as the legal guardian in Round 1 is present in the household in Round7.
legal>0 for N=60.;
legal=0;
do i=1 to dim(hhuid);
if uid~=. & uid=hhuid(i) then do;
legal=hhrel(i);
legal_ag=hhage(i);
end;
end;

** At least one member in the household is an adult (21 years and over);
do i=1 to dim(hhuid);
if hhage(i)>20 then adulthh=1;
end;


** Relation of Legal Guardian to Youth;

* Grandparent;
lgrand=0;
if 28<legal<37 then lgrand=1;

* Spouse;
lspouse=0;
if legal=1|legal=2 then lspouse=1;

* Siblings;
lsibs=0;
if 12<legal<19 & adulthh=1 then lsibs=1;

* Aunt/Uncle and Other Relatives;
lrltv=0;
if 69<legal<85 & adulthh=1 then lrltv=1;

* Lover/Roommate/Other Non-relative/Mother's or Father's Partner;
lnrltv=0;
if legal in (69,68,85,88,89) then lnrltv=1;

* Invalid;
linv=0;
if legal in (-1,-2,-3) then linv=1;

* Independent;
indep=1;
do i=1 to dim(hhuid);
if hhrel(i)>-4 then indep=0;
end;


** Relation of Non Legal Guardians to the Youth;

nlgrand=0; nlspouse=0; nlsibs=0; nlrltv=0; nlnrltv=0; nlinv=0;

do i=1 to dim(hhuid);

* Grandparent;
if 28<hhrel(i)<37 then nlgrand=1;

* Spouse;
if hhrel(i)=1|hhrel(i)=2 then nlspouse=1;

* Siblings;
if 12<hhrel(i)<19 & hhage(i)>20 then nlsibs=1;

* Aunt/Uncle and Other Relatives;
if 69<hhrel(i)<85 & hhage(i)>20 then nlrltv=1;

* Lover/Roommate/Other Non-relative/Mother's or Father's Partner;
if hhrel(i) in (69,68,85,88,89) then nlnrltv=1;

* Invalid;
if hhrel(i) in (-1,-2,-3) then nlinv=1;

end;


** For all youth;
grand=lgrand;
spouse=lspouse;
sibs=lsibs;
rltv=lrltv;
nrltv=lnrltv;
inv=linv;
if nlspouse~=. then spouse=nlspouse;


** Identifying the parent figure in the household;
mother=0; father=0; adpdad=0; adpmom=0; fstmom=0; fstdad=0; stpmom=0; stpdad=0; both=0;
do i=1 to dim(hhuid);
if hhrel(i)=3 then mother=i;
if hhrel(i)=4 then father=i;
if hhrel(i)=5 then adpmom=i;
if hhrel(i)=6 then adpdad=i;
if hhrel(i)=7 then stpmom=i;
if hhrel(i)=8 then stpdad=i;
if hhrel(i)=9 then fstmom=i;
if hhrel(i)=10 then fstdad=i;
end;
if mother>0 & father>0 then both=1;

** Creating the final variable - REL;
REL=10;
if inv=1 then REL=-3;
if indep=1|(inv~=1 & nrltv>0) then REL=10;
if inv~=1 & (rltv>0|sibs>0) then REL=9;
if grand>0 & mother=0 & father=0 then REL=8;
if spouse=1|stpdad>0|stpmom>0 then REL=10;
if fstdad>0|fstmom>0 then REL=7;
if adpmom>0|adpdad>0 then REL=6;
if father>0 & mother=0 then REL=5;
if mother>0 & father=0 then REL=4;
if father>0 & mother=0 & (adpmom>0|stpmom>0) then REL=3;
if mother>0 & father=0 & (adpdad>0|stpdad>0) then REL=2;
if mother>0 & father>0 then REL=1;

endsas;

 Return to top


Youth's Marital Status and Marital/Cohabitation History

Variables Created: CV_MARSTAT
                                CV_MARSTAT_COLLAPSED
                                CV_FIRST_COHAB_DATE_M
                                CV_FIRST_COHAB_DATE_Y
                                CV_FIRST_MARRY_DATE_M
                                CV_FIRST_MARRY_DATE_Y
                                CV_FIRST_COHAB_MONTH
                                CV_FIRST_MARRY_MONTH
                                CV_COHAB_TTL
                                CV_MARRIAGES_TTL

Variables Used

m700r5 YMAR_700_2001      
M45001r5 YMAR_4500_01_2001      
M45002r5 YMAR_4500_02_2001      
M45003r5 YMAR_4500_03_2001      
M45004r5 YMAR_4500_04_2001      
m54011r5 YMAR_5400_01_01_2001      
M54012r5 YMAR_5400_01_02_2001      
m54021r5 YMAR_5400_02_01_2001      
M54022r5 YMAR_5400_02_02_2001      
FCOH_Mr5 CV_FIRST_COHAB_DATE_M_2001      
FCOH_Yr5 CV_FIRST_COHAB_DATE_Y_2001      
FCOHCMr5 CV_FIRST_COHAB_MONTH_2001      
FMAR_Mr5 CV_FIRST_MARRY_DATE_M_2001      
FMAR_Yr5 CV_FIRST_MARRY_DATE_Y_2001      
FMARMr5 CV_FIRST_MARRY_MONTH_2001      
INT_Dr5 CV_INTERVIEW_DATE_D_2001      
INT_Mr5 CV_INTERVIEW_DATE_M_2001      
INT_Yr5 CV_INTERVIEW_DATE_Y_2001      
MARSTAT5 CV_MARSTAT_2001      
CMARSTA5 CV_MARSTAT_COLLAPSED_2001      
COH_TTL5 CV_COHAB_TTL_2001      
MAR_TTL5 CV_MARRIAGES_TTL_2001      
NORCID NORCID_2001      
         
M620 YMAR_620_2002      
M650 YMAR_650_2002      
M710 YMAR_710_2002      
M712 YMAR_712_2002      
M714 YMAR_714_2002      
M718 YMAR_718_2002      
M729D YMAR_729D_2002      
M730 YMAR_730_2002      
M740 YMAR_740_2002      
M760 YMAR_760_2002      
M2900 YMAR_2900      
M31001M YMAR_3100_01_M_2002      
M31001Y YMAR_3100_01_Y_2002      
M31002M YMAR_3100_02_M_2002      
M31002Y YMAR_3100_02_Y_2002      
M31003M YMAR_3100_03_M_2002      
M31003Y YMAR_3100_03_Y_2002      
m45001 YMAR_4500_01_2002      
M45002 YMAR_4500_02_2002      
M45003 YMAR_4500_03_2002      
M45004 YMAR_4500_04_2002      
M46501 YMAR_4650_01_2002      
M46502 YMAR_4650_02_2002      
M46503 YMAR_4650_03_2002      
M47001 YMAR_4700_01_2002      
M47002 YMAR_4700_02_2002      
M47003 YMAR_4700_03_2002      
M48001M YMAR_4800_01_M_2002      
M48001Y YMAR_4800_01_Y_2002      
M48002M YMAR_4800_02_M_2002      
M48002Y YMAR_4800_02_Y_2002      
M48003M YMAR_4800_03_M_2002      
M48003Y YMAR_4800_03_Y_2002      
M540011 YMAR_5400_01_01_2002      
M540012 YMAR_5400_01_02_2002      
M540013 YMAR_5400_01_03_2002      
M560012M YMAR_5600_01_01_M_2002      
M560012Y YMAR_5600_01_02_Y_2002      
M560013Y YMAR_5600_01_03_Y_2002      
M570011M YMAR_5700_01_01_M_2002      
M570011Y YMAR_5700_01_01_Y_2002      
M700011M YMAR_7000_01_01_M_2002      
M700011Y YMAR_7000_01_01_Y_2002      
M700012M YMAR_7000_01_02_M_2002      
M700012y YMAR_7000_01_02_Y_2002      
M700021M YMAR_7000_02_01_M_2002      
M700031Y YMAR_7000_03_01_Y_2002      
M7900111 YMAR_7900_01_01_01_2002      
M7900211 YMAR_7900_02_01_01_2002      
M810111M YMAR_8100_01_01_01_M_2002      
M810111Y YMAR_8100_01_01_01_Y_2002      
M8200111M YMAR_8200_01_01_01_M_2002      
M8200111Y YMAR_8200_01_01_01_Y_2002      
M8200112M YMAR_8200_01_01_02_M_2002      
M8200112Y YMAR_8200_01_01_02_Y_2002      
M8200211M YMAR_8200_02_01_01_M_2002      
M8200211Y YMAR_8200_02_01_01_Y_2002      
M910011 YMAR_9100_01_01_2002      
M910012 YMAR_9100_01_02_2002      
M910021 YMAR_9100_02_01_2002      
M920011M YMAR_9200_01_01_M_2002      
M920011Y YMAR_9200_01_01_Y_2002      
M920021M YMAR_9200_02_01_M_2002      
M920021Y YMAR_9200_02_01_Y_2002      
m11700011y YMAR_11700_01_Y_2002      
m11700011m YMAR_11700_02_M_2002      
M114001 YMAR_11400_01_2002      
M114002 YMAR_11400_02_2002      
M114003 YMAR_11400_03_2002      
INT_D CV_INTERVIEW_DATE_D_2002      
INT_M CV_INTERVIEW_DATE_M_2002      
INT_Y CV_INTERVIEW_DATE_Y_2002      
M620 YMAR_620_2003      
M650 YMAR_650_2003      
M710 YMAR_710_2003      
M712 YMAR_712_2003      
M714 YMAR_714_2003      
M718 YMAR_718_2003      
M729D YMAR_729D_2003      
M730 YMAR_730_2003      
M740 YMAR_740_2003      
M760 YMAR_760_2003      
M2900 YMAR_2900_2003      
M31001M YMAR_3100_01_M_2003      
M31001Y YMAR_3100_01_Y_2003      
M31002M YMAR_3100_02_M_2003      
M31002Y YMAR_3100_02_Y_2003      
M31003M YMAR_3100_03_M_2003      
M31003Y YMAR_3100_03_Y_2003      
m45001 YMAR_4500_01_2003      
M45002 YMAR_4500_02_2003      
M45003 YMAR_4500_03_2003      
M45004 YMAR_4500_04_2003      
M46501 YMAR_4650_01_2003      
M46502 YMAR_4650_02_2003      
M46503 YMAR_4650_03_2003      
M47001 YMAR_4700_01_2003      
M47002 YMAR_4700_02_2003      
M47003 YMAR_4700_03_2003      
M48001M YMAR_4800_01_M_2003      
M48001Y YMAR_4800_01_Y_2003      
M48002M YMAR_4800_02_M_2003      
M48002Y YMAR_4800_02_Y_2003      
M48003M YMAR_4800_03_M_2003      
M48003Y YMAR_4800_03_Y_2003      
M540011 YMAR_5400_01_01_2003      
M540012 YMAR_5400_01_02_2003      
M540013 YMAR_5400_01_03_2003      
M560012M YMAR_5600_01_01_M_2003      
M560012Y YMAR_5600_01_02_Y_2003      
M560013Y YMAR_5600_01_03_Y_2003      
M570011M YMAR_5700_01_01_M_2003      
M570011Y YMAR_5700_01_01_Y_2003      
M700011M YMAR_7000_01_01_M_2003      
M700011Y YMAR_7000_01_01_Y_2003      
M700012M YMAR_7000_01_02_M_2003      
M700012y YMAR_7000_01_02_Y_2003      
M700021M YMAR_7000_02_01_M_2003      
M700031Y YMAR_7000_03_01_Y_2003      
M7900111 YMAR_7900_01_01_01_2003      
M7900211 YMAR_7900_02_01_01_2003      
M810111M YMAR_8100_01_01_01_M_2003      
M810111Y YMAR_8100_01_01_01_Y_2003      
M8200111M YMAR_8200_01_01_01_M_2003      
M8200111Y YMAR_8200_01_01_01_Y_2003      
M8200112M YMAR_8200_01_01_02_M_2003      
M8200112Y YMAR_8200_01_01_02_Y_2003      
M8200211M YMAR_8200_02_01_01_M_2003      
M8200211Y YMAR_8200_02_01_01_Y_2003      
M910011 YMAR_9100_01_01_2003      
M910012 YMAR_9100_01_02_2003      
M910021 YMAR_9100_02_01_2003      
M920011M YMAR_9200_01_01_M_2003      
M920011Y YMAR_9200_01_01_Y_2003      
M920021M YMAR_9200_02_01_M_2003      
M920021Y YMAR_9200_02_01_Y_2003      
m11700011y YMAR_11700_01_Y_2003      
m11700011m YMAR_11700_02_M_2003      
M114001 YMAR_11400_01_2003      
M114002 YMAR_11400_02_2003      
M114003 YMAR_11400_03_2003      
INT_D CV_INTERVIEW_DATE_D_2003      
INT_M CV_INTERVIEW_DATE_M_2003      
INT_Y CV_INTERVIEW_DATE_Y_2003      

 

Name in Program

Question Name on CD

 

Name in Program

Question Name on CD

m700r1 YMAR.700.1997   M45004 YMAR_4500_04_2002
m45001r1 YMAR.4500.01.1997   M46501 YMAR_4650_01_2002
m45002r1 YMAR.4500.02.1997   M46502 YMAR_4650_02_2002
m540011r1 YMAR.5400.01.01.1997   M46503 YMAR_4650_03_2002
m540012r1 YMAR.5400.01.02.1997   M47001 YMAR_4700_01_2002
FCOH.Mr1 CV.FIRST.COHAB.DATE.M.1997   M47002 YMAR_4700_02_2002
FCOH.Yr1 CV.FIRST.COHAB.DATE.Y.1997   M47003 YMAR_4700_03_2002
FCOHCMr1 CV.FIRST.COHAB.MONTH.1997   M48001M YMAR_4800_01_M_2002
FMAR.Mr1 CV.FIRST.MARRY.DATE.M.1997   M48001Y YMAR_4800_01_Y_2002
FMAR.Yr1 CV.FIRST.MARRY.DATE.Y.1997   M48002M YMAR_4800_02_M_2002
FMARMr1 CV.FIRST.MARRY.MONTH.1997   M48002Y YMAR_4800_02_Y_2002
INT.Dr1 CV.INTERVIEW.DATE.D.1997   M48003M YMAR_4800_03_M_2002
INT.Mr1 CV.INTERVIEW.DATE.M.1997   M48003Y YMAR_4800_03_Y_2002
INT.Yr1 CV.INTERVIEW.DATE.Y.1997   M540011 YMAR_5400_01_01_2002
MARSTAT1 CV.MARSTAT.1997   M540012 YMAR_5400_01_02_2002
CMARSTA1 CV.MARSTAT.COLLAPSED.1997   M540013 YMAR_5400_01_03_2002
COH.TTL1 CV.MARRIAGES.TTL.1997   M560012M YMAR_5600_01_01_M_2002
MAR.TTL1 CV.MARRIAGES.TTL.1997   M560012Y YMAR_5600_01_02_Y_2002
  M560013Y YMAR_5600_01_03_Y_2002
m700r2 YMAR.700.1998   M570011M YMAR_5700_01_01_M_2002
M45001r2 YMAR.4500.01.1998   M570011Y YMAR_5700_01_01_Y_2002
M45002r2 YMAR.4500.02.1998   M700011M YMAR_7000_01_01_M_2002
M45003r2 YMAR.4500.03.1998   M700011Y YMAR_7000_01_01_Y_2002
M54011r2 YMAR.5400.01.01.1998   M700012M YMAR_7000_01_02_M_2002
M54012r2 YMAR.5400.01.02.1998   M700012y YMAR_7000_01_02_Y_2002
FCOH.Mr2 CV.FIRST.COHAB.DATE.M.1998   M700021M YMAR_7000_02_01_M_2002
FCOH.Yr2 CV.FIRST.COHAB.DATE.Y.1998   M700031Y YMAR_7000_03_01_Y_2002
FCOHCMr2 CV.FIRST.COHAB.MONTH.1998   M7900111 YMAR_7900_01_01_01_2002
FMAR.Mr2 CV.FIRST.MARRY.DATE.M.1998   M7900211 YMAR_7900_02_01_01_2002
FMAR.Yr2 CV.FIRST.MARRY.DATE.Y.1998   M810111M YMAR_8100_01_01_01_M_2002
FMARMr2 CV.FIRST.MARRY.MONTH.1998   M810111Y YMAR_8100_01_01_01_Y_2002
INT.Dr2 CV.INTERVIEW.DATE.D.1998   M8200111M YMAR_8200_01_01_01_M_2002
INT.Mr2 CV.INTERVIEW.DATE.M.1998   M8200111Y YMAR_8200_01_01_01_Y_2002
INT.Yr2 CV.INTERVIEW.DATE.Y.1998   M8200112M YMAR_8200_01_01_02_M_2002
MARSTAT2 CV.MARSTAT.1998   M8200112Y YMAR_8200_01_01_02_Y_2002
CMARSTA2 CV.MARSTAT.COLLAPSED.1998   M8200211M YMAR_8200_02_01_01_M_2002
COH.TTL2 CV.COHAB.TTL.1998   M8200211Y YMAR_8200_02_01_01_Y_2002
MAR.TTL2 CV.MARRIAGES.TTL.1998   M910011 YMAR_9100_01_01_2002
  M910012 YMAR_9100_01_02_2002
m700r3 YMAR.700.1999   M910021 YMAR_9100_02_01_2002
M45001r3 YMAR.4500.01.1999   M920011M YMAR_9200_01_01_M_2002
M45002r3 YMAR.4500.02.1999   M920011Y YMAR_9200_01_01_Y_2002
m54011r3 YMAR.5400.01.01.1999   M920021M YMAR_9200_02_01_M_2002
M54012r3 YMAR.5400.01.02.1999   M920021Y YMAR_9200_02_01_Y_2002
FCOH.Mr3 CV.FIRST.COHAB.DATE.M.1999   m11700011y YMAR_11700_01_Y_2002
FCOH.Yr3 CV.FIRST.COHAB.DATE.Y.1999   m11700011m YMAR_11700_02_M_2002
FCOHCMr3 CV.FIRST.COHAB.MONTH.1999   M114001 YMAR_11400_01_2002
FMAR.Mr3 CV.FIRST.MARRY.DATE.M.1999   M114002 YMAR_11400_02_2002
FMAR.Yr3 CV.FIRST.MARRY.DATE.Y.1999   M114003 YMAR_11400_03_2002
FMARMr3 CV.FIRST.MARRY.MONTH.1999   INT_D CV_INTERVIEW_DATE_D_2002
INT.Dr3 CV.INTERVIEW.DATE.D.1999   INT_M CV_INTERVIEW_DATE_M_2002
INT.Mr3 CV.INTERVIEW.DATE.M.1999   INT_Y CV_INTERVIEW_DATE_Y_2002
INT.Yr3 CV.INTERVIEW.DATE.Y.1999      
MARSTAT3 CV.MARSTAT.1999   M620 YMAR_620_2003
CMARSTA3 CV.MARSTAT.COLLAPSED.1999   M650 YMAR_650_2003
COH.TTL3 CV.COHAB.TTL.1999   M710 YMAR_710_2003
MAR.TTL3 CV.MARRIAGES.TTL.1999   M712 YMAR_712_2003
  M714 YMAR_714_2003
m700r4 YMAR.700.2000   M718 YMAR_718_2003
M45001r4 YMAR.4500.01.2000   M729D YMAR_729D_2003
M45002r4 YMAR.4500.02.2000   M730 YMAR_730_2003
M45003r4 YMAR.4500.03.2000   M740 YMAR_740_2003
M45004r4 YMAR.4500.04.2000   M760 YMAR_760_2003
m54011r4 YMAR.5400.01.01.2000   M2900 YMAR_2900_2003
M54012r4 YMAR.5400.01.02.2000   M31001M YMAR_3100_01_M_2003
m54021r4 YMAR.5400.02.01.2000   M31001Y YMAR_3100_01_Y_2003
M54022r4 YMAR.5400.02.02.2000   M31002M YMAR_3100_02_M_2003
FCOH.Mr4 CV.FIRST.COHAB.DATE.M.2000   M31002Y YMAR_3100_02_Y_2003
FCOH.Yr4 CV.FIRST.COHAB.DATE.Y.2000   M31003M YMAR_3100_03_M_2003
FCOHCMr4 CV.FIRST.COHAB.MONTH.2000   M31003Y YMAR_3100_03_Y_2003
FMAR.Mr4 CV.FIRST.MARRY.DATE.M.2000   m45001 YMAR_4500_01_2003
FMAR.Yr4 CV.FIRST.MARRY.DATE.Y.2000   M45002 YMAR_4500_02_2003
FMARMr4 CV.FIRST.MARRY.MONTH.2000   M45003 YMAR_4500_03_2003
INT.Dr4 CV.INTERVIEW.DATE.D.2000   M45004 YMAR_4500_04_2003
INT.Mr4 CV.INTERVIEW.DATE.M.2000   M46501 YMAR_4650_01_2003
INT.Yr4 CV.INTERVIEW.DATE.Y.2000   M46502 YMAR_4650_02_2003
MARSTAT4 CV.MARSTAT.2000   M46503 YMAR_4650_03_2003
CMARSTA4 CV.MARSTAT.COLLAPSED.2000   M47001 YMAR_4700_01_2003
COH.TTL4 CV.COHAB.TTL.2000   M47002 YMAR_4700_02_2003
MAR.TTL4 CV.MARRIAGES.TTL.2000   M47003 YMAR_4700_03_2003
      M48001M YMAR_4800_01_M_2003
m700r5 YMAR_700_2001   M48001Y YMAR_4800_01_Y_2003
M45001r5 YMAR_4500_01_2001   M48002M YMAR_4800_02_M_2003
M45002r5 YMAR_4500_02_2001   M48002Y YMAR_4800_02_Y_2003
M45003r5 YMAR_4500_03_2001   M48003M YMAR_4800_03_M_2003
M45004r5 YMAR_4500_04_2001   M48003Y YMAR_4800_03_Y_2003
m54011r5 YMAR_5400_01_01_2001   M540011 YMAR_5400_01_01_2003
M54012r5 YMAR_5400_01_02_2001   M540012 YMAR_5400_01_02_2003
m54021r5 YMAR_5400_02_01_2001   M540013 YMAR_5400_01_03_2003
M54022r5 YMAR_5400_02_02_2001   M560012M YMAR_5600_01_01_M_2003
FCOH_Mr5 CV_FIRST_COHAB_DATE_M_2001   M560012Y YMAR_5600_01_02_Y_2003
FCOH_Yr5 CV_FIRST_COHAB_DATE_Y_2001   M560013Y YMAR_5600_01_03_Y_2003
FCOHCMr5 CV_FIRST_COHAB_MONTH_2001   M570011M YMAR_5700_01_01_M_2003
FMAR_Mr5 CV_FIRST_MARRY_DATE_M_2001   M570011Y YMAR_5700_01_01_Y_2003
FMAR_Yr5 CV_FIRST_MARRY_DATE_Y_2001   M700011M YMAR_7000_01_01_M_2003
FMARMr5 CV_FIRST_MARRY_MONTH_2001   M700011Y YMAR_7000_01_01_Y_2003
INT_Dr5 CV_INTERVIEW_DATE_D_2001   M700012M YMAR_7000_01_02_M_2003
INT_Mr5 CV_INTERVIEW_DATE_M_2001   M700012y YMAR_7000_01_02_Y_2003
INT_Yr5 CV_INTERVIEW_DATE_Y_2001   M700021M YMAR_7000_02_01_M_2003
MARSTAT5 CV_MARSTAT_2001   M700031Y YMAR_7000_03_01_Y_2003
CMARSTA5 CV_MARSTAT_COLLAPSED_2001   M7900111 YMAR_7900_01_01_01_2003
COH_TTL5 CV_COHAB_TTL_2001   M7900211 YMAR_7900_02_01_01_2003
MAR_TTL5 CV_MARRIAGES_TTL_2001   M810111M YMAR_8100_01_01_01_M_2003
      M810111Y YMAR_8100_01_01_01_Y_2003
M620 YMAR_620_2002   M8200111M YMAR_8200_01_01_01_M_2003
M650 YMAR_650_2002   M8200111Y YMAR_8200_01_01_01_Y_2003
M710 YMAR_710_2002   M8200112M YMAR_8200_01_01_02_M_2003
M712 YMAR_712_2002   M8200112Y YMAR_8200_01_01_02_Y_2003
M714 YMAR_714_2002   M8200211M YMAR_8200_02_01_01_M_2003
M718 YMAR_718_2002   M8200211Y YMAR_8200_02_01_01_Y_2003
M729D YMAR_729D_2002   M910011 YMAR_9100_01_01_2003
M730 YMAR_730_2002   M910012 YMAR_9100_01_02_2003
M740 YMAR_740_2002   M910021 YMAR_9100_02_01_2003
M760 YMAR_760_2002   M920011M YMAR_9200_01_01_M_2003
M2900 YMAR_2900   M920011Y YMAR_9200_01_01_Y_2003
M31001M YMAR_3100_01_M_2002   M920021M YMAR_9200_02_01_M_2003
M31001Y YMAR_3100_01_Y_2002   M920021Y YMAR_9200_02_01_Y_2003
M31002M YMAR_3100_02_M_2002   m11700011y YMAR_11700_01_Y_2003
M31002Y YMAR_3100_02_Y_2002   m11700011m YMAR_11700_02_M_2003
M31003M YMAR_3100_03_M_2002   M114001 YMAR_11400_01_2003
M31003Y YMAR_3100_03_Y_2002   M114002 YMAR_11400_02_2003
m45001 YMAR_4500_01_2002   M114003 YMAR_11400_03_2003
M45002 YMAR_4500_02_2002   INT_D CV_INTERVIEW_DATE_D_2003
M45003 YMAR_4500_03_2002   INT_M CV_INTERVIEW_DATE_M_2003
      INT_Y CV_INTERVIEW_DATE_Y_2003

Codes for Created Variable

Marital/Cohabitation Status

1 = never married, cohabiting
2 = never married, not cohabiting
3 = married, spouse present
4 = married, spouse absent
5 = separated, cohabiting

6 = separated, not cohabiting
7 = divorced, cohabiting
8 = divorced, not cohabiting
9 = widowed, cohabiting
10 = widowed, not cohabiting

 

Collapsed Marital Status

0 = never married
1 = married
2 = separated
3 = divorced
4 = widowed

 

Marital Status in Event History
0 = never married, not cohabiting
1 = never married, cohabiting
2 = married
3 = separated
4 = divorced
5 = widowed

This program creates two variables that describe marital status/cohabitation status as of the interview date for respondents age 16 and older.  Other respondents are valid skips (-4).  Note that later partners take precedence over earlier partners.

The program also creates variables that provide the dates of the youth's first marriage and/or cohabitation in both a continuous month scheme and as actual dates (for more information on the continuous month scheme, see appendix 7 in this document). Summary variables count the total number of marriages and cohabitations for each youth. If a respondent is cohabiting and then marries it is considered both a cohabitation and a marriage. If someone refuses or doesn't know the full date of their marriage or cohabitation, then the spell is counted in the total variables and the date variables are coded -1 or -2 as applicable.


array int_cmr {6} int_cmr1 - int_cmr6;

if M31001m>0 and M31001y>0 then do;
coh31001=((M31001Y-1980)*12)+M31001M;
end;

if M31002m>0 and M31002y>0 then do;
coh31002=((M31002Y-1980)*12)+M31002M;
end;

if M48001m>0 and M48001y>0 then do;
end48001=((M48001Y-1980)*12)+M48001M;
end;
if M48002m>0 and M48002y>0 then do;
end48002=((M48002Y-1980)*12)+M48002M;
end;
if M48003m>0 and M48003y>0 then do;
end48003=((M48003Y-1980)*12)+M48003M;
end;
if M560011m>0 and M560011y>0 then do;
mar560011=((M560011Y-1980)*12)+M560011M;
end;
if M560012m>0 and M560012y>0 then do;
mar560012=((M560012Y-1980)*12)+M560012M;
end;

if M570011m>0 and M570011y>0 then do;
mar570011=((M570011Y-1980)*12)+M570011M;
end;
if M700011m>0 and M700011y>0 then do;
coh700011=((M700011Y-1980)*12)+M700011M;
end;
if M700012m>0 and M700012y>0 then do;
coh700012=((M700012Y-1980)*12)+M700012M;
end;
if M700021m>0 and M700021y>0 then do;
coh700021=((M700021Y-1980)*12)+M700021M;
end;
if M8200111m>0 and M8200111y>0 then do;
mar8200111=((M8200111Y-1980)*12)+M8200111M;
end;
if M10100111m>0 and M10100111y>0 then do;
coh10100111=((M10100111Y-1980)*12)+M10100111m;
end;
if M117001m>0 and M117001y>0 then do;
coh117001=((M117001Y-1980)*12)+M117001m;
end;


do i=1 to 6;
if coh31001>0 and coh31001<int_cmr{i} and p1<700 then do;
flag31001=1;
end;

if coh31002>0 and coh31002<int_cmr{i} and p2<700 then do;
flag31002=1;
end;

flag48001a=0;
if end48001>0 and end48001<int_cmr{i} and p1<700 then do;
flag48001a=1;
end;

flag48002a=0;
if end48002>0 and end48002<int_cmr{i} and p2<700 then do;
flag48002a=1;
end;

flag560011=0;
if mar560011>0 and mar560011<int_cmr{i} and p1<700 then do;
flag560011=1;
end;

flag560012=0;
if mar560012>0 and mar560012<int_cmr{i} and p1<700 then do;
flag560012=1;
end;

flag570011=0;
if mar570011>0 and mar570011<int_cmr{i} and p1<700 then do;
flag570011=1;
end;

flag700011=0;
if coh700011>0 and coh700011<int_cmr{i} and p1<700 then do;
flag700011=1;
end;

flag700012=0;
if coh700012>0 and coh700012<int_cmr{i} and p1<700 then do;
flag700012=1;
end;

flag700021=0;
if coh700021>0 and coh700021<int_cmr{i} and p1<700 then do;
flag700021=1;
end;

flag8200111=0;
if mar8200111>0 and mar8200111<int_cmr{i} and p1<700 then do;
flag8200111=1;
end;

flag10100111=0;
if coh10100111>0 and coh10100111<int_cmr{i} and p1<700 then do;
flag10100111=1;
end;

flag117001=0;
if coh117001>0 and coh117001<int_cmr{i} and p1<700 then do;
flag1117001=1;
end;
end;

flag31001a=0;
if (-4<m31001m<0 or -4<m31001y<0) and p1<700then do ;
flag31001a=1;
if flag31001a=1 then flag31001=1;
end;

if flag31001=1 or flag31002 =1 or
flag48001a=1 or flag48002a=1 or flag570011=1 or
flag700011=1 or
flag8200111=1 or
flag10100111=1 then flagdc=1;

/* Married in previous round,back living with previous spouse, but reported cohabitation data before dli*/
if PUBID in (8230, 6605, 1705, 8309, 2157, 5167, 6805, 1386) then do;
m45001=1;
end;

/* set up stopping month as December*/
if PUBID=6665 then m8100111m=12;
if PUBID=8751 then m48001m=5;

/* Comments R only lived with partner */
if PUBID=7514 then m7900111=-4;
if PUBID=6713 then m7900111=-4;
/*Comments married Dec. 2002 but did not begin living together until Feb 2003*/
if PUBID= 587 then do;
m8200111m=12;
m8200111y=2002;
end;

/*Comments married at The month was August 2003.*/
if PUBID=4805 then m8200111y=2003;
/*R's reported two partners, partner one reported at last round and cohabitation data before dli
partner two is new partner */
if PUBID in (8999, 5324, 6169) then do;
m31001m=m31002m;
m31001y=m31002y;
m47001=1;
m31002m=-4;
m31002y=-4;
m47002=-4;
m48001y=-4;
m48001m=-4;
p1=p2;
p2=-4;
end;

if PUBID=3434 then do;
m114001=-4;
m117001m=-4;
m117001y=-4;
end;

/* R's denies any marriage like relationship */
if PUBID =7095 then do;
m31001y=-4;
m31001m=-4;
m45001=-4;
m48001m=-4;
m48001y=-4;
m114001=-4;
end;

if PUBID in (7830,802) then m114001=-4;

/* R's separated but for some reason they answer m46701=1, correct m46701=0 and put the stopping cohabitation data*/
if PUBID in (159,3678,5901,6665,8969) then do;
m46701=0;
m48001m=m8100111m;
m48001y=m8100111y;
end;

if PUBID=6039 then do;
m47002=0;
m48002m=m8100211m;
m48002y=m8100211y;
end;

if PUBID=6474 then do;
m7900111=4;
m8100111m=12;
m8100111y=2002;
end;

/* comments: R's got married in March 2003*/
if PUBID =6959then m8200111m=3;

/* Annulment, but no data */
if PUBID=4692 then m114001=-4;
if PUBID=1420 then m540011=-4;
/* Only one partner name in Partner Roster. But there two loops in partner Roster. */
if PUBID in

(784,
2016,
5237,
7095,
7197,
7903,
8357) then flagpa1=1;

/*Respondents only have one partner name in the Partner Roster. But there are two loops in the partner Roster. */
if PUBID=784 then do;
m31002m=-4;
m31002y=-4;
m47002=-4;
end;

if PUBID = 5237 then do;
m31001m=m31002m;
m31001y=m31002y;
m48001m=m48002m;
m48001y=m48002y;
m48002m=-4;
m48002y=-4;
m31002m=-4;
m31002y=-4;
p1=p2;
p2=-4;
end;

/* Set up initial marital status by using dli created variables. */
if cmarsta6 ne -5 then do;
prevmsta=MARSTAT6;
prevcmst=CMARSTA6;
mar_ttl=mar_ttl6;
coh_ttl=coh_ttl6;
premar_ttl=mar_ttl6;
precoh_ttl=coh_ttl6;
prevmary=FMAR_Yr6;
prevmarm=FMAR_Mr6;
prvmarcm=fmarmr6;
prevcohm=FCOH_Mr6;
prevcohy=FCOH_Yr6;
prvcohcm=FCOHCMr6;
dliym=int_yr6*100+int_mr6;
dlicm=(int_yr6-1980)*12+int_mr6;
mardli=marstat6;
end;

/*Round 6 noninterview, go to round 5*/
else if cmarsta6=-5 and cmarsta5 ne -5 then do;
prevmsta=MARSTAT5;
prevcmst=CMARSTA5;
mar_ttl=mar_ttl5;
coh_ttl=coh_ttl5;
premar_ttl=mar_ttl5;
precoh_ttl=coh_ttl5;
prevmary=FMAR_Yr5;
prevmarm=FMAR_Mr5;
prvmarcm=fmarmr5;
prevcohm=FCOH_Mr5;
prevcohy=FCOH_Yr5;
prvcohcm=FCOHCMr5;
dliym=int_yr5*100+int_mr5;
dlicm=(int_yr5-1980)*12+int_mr5;
mardli=marstat5;
end;

/*Round 5 no interview, go to round 4*/
else if cmarsta6=-5 and cmarsta5=-5 and cmarsta4 ne -5 then do;
prevmsta=MARSTAT4;
prevcmst=CMARSTA4;
premar_ttl=mar_ttl4;
precoh_ttl=coh_ttl4;
mar_ttl=mar_ttl4;
coh_ttl=coh_ttl4;
prevmary=FMAR_Yr4;
prevmarm=FMAR_Mr4;
prvmarcm=fmarmr4;
prevcohm=FCOH_Mr4;
prevcohy=FCOH_Yr4;
prvcohcm=FCOHCMr4;
dliym=int_yr4*100+int_mr4;
dlicm=(int_yr4-1980)*12+int_mr4;
mardli=marstat4;
end;

/*Round 4 no interview, go to round 3*/
else if cmarsta6=-5 and cmarsta5=-5 and cmarsta4=-5 and cmarsta3 ne -5 then do;
prevmsta=marstat3;
prevcmst=cmarsta3;
premar_ttl=mar_ttl3;
precoh_ttl=coh_ttl3;
mar_ttl=mar_ttl3;
coh_ttl=coh_ttl3;
prevmary=FMAR_Yr3;
prevmarm=FMAR_Mr3;
prvmarcm=fmarmr3;
prevcohm=FCOH_Mr3;
prevcohy=FCOH_Yr3;
prvcohcm=FCOHCMr3;
dliym=int_yr3*100+int_mr3;
dlicm=(int_yr3-1980)*12+int_mr3;
mardli=marstat3;
end;

/*Round 3 no interview, go to round 2*/
else if cmarsta6=-5 and cmarsta5=-5 and cmarsta4=-5 and cmarsta3=-5 and cmarsta2 ne -5 then do;
prevmsta=marstat2;
prevcmst=cmarsta2;
premar_ttl=mar_ttl2;
precoh_ttl=coh_ttl2;
mar_ttl=mar_ttl2;
coh_ttl=coh_ttl2;
prevmary=FMAR_Yr2;
prevmarm=FMAR_Mr2;
prvmarcm=fmarmr2;
prevcohm=FCOH_Mr2;
prevcohy=FCOH_Yr2;
prvcohcm=FCOHCMr2;
dliym=int_yr2*100+int_mr2;
dlicm=(int_yr2-1980)*12+int_mr2;
mardli=marstat2;
end;

/*Round5 round4 round3 and round 2 no interview, go to round 1*/
else if cmarsta6=-5 and cmarsta5=-5 and cmarsta4=-5 and cmarsta3=-5 and cmarsta2=-5 and cmarsta1 ne -5 then do;
prevmsta=marstat1;
prevcmst=cmarsta1;
premar_ttl=mar_ttl1;
precoh_ttl=coh_ttl1;
mar_ttl=mar_ttl1;
coh_ttl=coh_ttl1;
prevmary=FMAR_Yr1;
prevmarm=FMAR_Mr1;
prvmarcm=fmarmr1;
prevcohm=FCOH_Mr1;
prevcohy=FCOH_Yr1;
prvcohcm=FCOHCMr1;
dliym=int_yr1*100+int_mr1;
dlicm=(int_yr1-1980)*12+int_mr1;
mardli=marstat1;
end;

/* 6-19-04 Set up the c.v.'s for first marriage and first cohab and the dli value for each respective c.v. */
dlicohy=prevcohy;
dlicohm=prevcohm;
dlicohcm=prvcohcm;
dlimary=prevmary;
dlimarm=prevmarm;
dlimarcm=prvmarcm;

/* Create interview date and previous interview date in continuous
months and months/years;*/

if int_y gt 0 and int_m gt 0 then do;
iym=int_y*100+int_m;
doicm=(int_y-1980)*12+int_m;
end;

else if int_y eq -5 or int_m eq -5 then do;
doicm=-5;
iym=-5;
end;

else if int_y in(-1,-2, -3) or int_m in(-1, -2, -3) then do;

doicm=-3;
iym=-3;
end;

/* Create variable START, start a month after dl1 */
start=dlicm+1;

/* Partner flag to check old partner or new partner*/
if (p1=p1r6 or p1=p1r5 or p1=p1r4 or p1=p1r3 or p1=p1r2 or p1=p1r1) and P1>0 then flagp1=1;
if (p1=p2r6 or p1=p2r5 or p1=p2r4 or p1=p2r3 or p1=p2r2 or p1=p2r1) and p1>0 then flagp1=1;
if (p1=p3r6 or p1=p3r5 or p1=p3r4 or p1=p3r2 ) and p1>0 then flagp1=1;

if (p2=p1r6 or p2=p1r5 or p2=p1r4 or p2=p1r3 or p2=p1r2 or p2=p1r1) and p2>0 then flagp2=1;
if (p2=p2r6 or p2=p2r5 or p2=p2r4 or p2=p2r3 or p2=p2r2 or p2=p2r1) and p2>0 then flagp2=1;
if (p2=p2r6 or p2=p3r5 or p2=p3r4 or p2=p3r2 ) and p2>0 then flagp2=1;

if (p3=p1r6 or p3=p1r5 or p3=p1r4 or p3=p1r3 or p3=p1r2 or p3=p1r1) and P3>0 then flagp3=1;
if (p3=p2r6 or p3=p2r5 or p3=p2r4 or p3=p2r3 or p3=p2r2 or p3=p2r1) and p3>0 then flagp3=1;
if (p3=p3r6 or p3=p3r5 or p3=p3r4 or p3=p3r2 ) and p3>0 then flagp3=1;

/*Reported stopping cohabitation before or at dli */
flag48001=0;
if M48001M>0 and M48001Y>0 then end48001=((M48001Y-1980)*12)+M48001M;
if (0<end48001<=dlicm and flagp1=1 or 0<end48001<=dlicm+1 and flagp1=1)
then flag48001=1;

flag48002=0;
if M48002M>0 and M48002Y>0 then end48002=((M48002Y-1980)*12)+M48002M;
if (0<end48002<=dlicm and flagp2=1 or 0<end48002<=dlicm+1 and flagp2=1)
then flag48002=1;
/* new partner Reported stopping cohabitation before or at dli */
flagbacknew=0;
if (0<end48001<=dlicm and p1>=701) or (0<end48002<=dlicm and p2>=701) then flagbacknew=1;

/* set up arrays for r6 partner and spouse*/
array r6mars (l) r6mars001-r6mars295;
array r6co (l) r6co001-r6co295;
array r6link (l) r6link001-r6link295;
array r6pt (l) r6pt001-r6pt295;
array r6sp (l) r6sp001-r6sp295;

/* set up arrays for r7 partner and spouse*/
array r7pt (l) r7pt001-r7pt295;
array r7sp (l) r7sp001-r7sp295;

/* set up Mar arrays for each partner in four period*/
array maf (l) maf001-maf295;
array mas (l) mas001-mas295;
array mat (l) mat001-mat295;
array mafour (l) mafour001-mafour295;

array mbf (l) mbf001-mbf295;
array mbs (l) mbs001-mbs295;
array mbt (l) mbt001-mbt295;
array mbfour (l) mbfour001-mbfour295;

array mcf (l) mcf001-mcf295;
array mcs (l) mcs001-mcs295;
array mct (l) mct001-mct295;
array mcfour (l) mcfour001-mcfour295;

array mdf (l) mdf001-mdf295;
array mds (l) mds001-mds295;
array mdt (l) mdt001-mdt295;
array mdfour (l) mdfour001-mdfour295;

/* array for partner a in first sec third and fourth period*/
array maa (l) maa001-maa295;
array mbb (l) mbb001-mbb295;
array mcc (l) mcc001-mcc295;
array mdd (l) mdd001-mdd295;

/* set up arrays for mar total*/
array mal (l) mal001-mal295;

/* Set up cohabitation arrays for each partner in four period*/
array cohaf (l) cohaf001-cohaf295;
array cohas (l) cohas001-cohas295;
array cohat (l) cohat001-cohat295;
array cohafour (l) cohafour001-cohafour295;

array cohbf (l) cohbf001-cohbf295;
array cohbs (l) cohbs001-cohbs295;
array cohbt (l) cohbt001-cohbt295;
array cohbfour (l) cohbfour001-cohbfour295;

array cohcf (l) cohcf001-cohcf295;
array cohcs (l) cohcs001-cohcs295;
array cohct (l) cohct001-cohct295;
array cohcfour (l) cohcfour001-cohcfour295;

array cohdf (l) cohdf001-cohdf295;
array cohds (l) cohds001-cohds295;
array cohdt (l) cohdt001-cohdt295;
array cohdfour (l) cohdfour001-cohdfour295;

array cohaa (l) cohaa001-cohaa295;
array cohbb (l) cohbb001-cohbb295;
array cohcc (l) cohcc001-cohcc295;
array cohdd (l) cohdd001-cohdd295;

/*Cohabitation total*/
array cohal (l) cohal001-cohal295;

/*arrays for event history */
array mars (l) mars001-mars295;
array cohh (l) cohh001-cohh295;
array link (l) link001-link295;
array dual (l) dual001-dual295;

do l=start to 295;

cohal=0;
cohaf=0;
cohas=0;
cohat=0;
cohafour=0;


cohbf=0;
cohbs=0;
cohbt=0;
cohbfour=0;

cohcf=0;
cohcs=0;
cohct=0;
cohcfour=0;

cohdf=0;
cohds=0;
cohdt=0;
cohdfour=0;

mal=0;
maf=0;
mas=0;
mat=0;
mafour=0;

mbf=0;
mbs=0;
mbt=0;
mbfour=0;

mcf=0;
mcs=0;
mct=0;
mcfour=0;

mdf=0;
mds=0;
mdt=0;
mdfour=0;

end;
/*In the array section, an index by "p" indicates a loop over partners,
while an index by "t" indicates a loop over time periods. */
/* year start cohabitating*/
/* yscd2: year start cohabitating with partner d prd 2 */

array ysca (t) M31001Y M700011Y M700012Y M700013Y;
array yscb (t) M31002Y M700021Y M700022Y yscb4;
array yscc (t) M31003Y yscc2 yscc3 yscc4;
array yscd (t) yscd1 yscd2 yscd3 yscd4;

array msca (t) M31001M M700011M M700012M M700013M;
array mscb (t) M31002M M700021M M700022M mscb4;
array mscc (t) M31003M mscc3 mscb3 mscb4;
array mscd (t) mscd1 mscd2 mscd3 mscd4;

array ysc (p) ysca yscb yscc yscd;
array msc (p) msca mscb mscc mscd;

/*year end cohabitating (not continuous)*/
array yeca (t) M48001Y M920011Y M920012Y yeca4;
array yecb (t) M48002Y M920021Y M920022Y yecb4;
array yecc (t) M48003Y yecc2 yecc3 yecc4;
array yecd (t) yecd1 yecd2 yecd3 yecd4;
array yec (p) yeca yecb yecc yecd;

/*month end cohabitating (not continuous)*/
array meca (t) M48001M M920011M M920012M meca4;
array mecb (t) M48002M M920021M M920022M mecb4;
array mecc (t) M48003M mecc2 mecc3 mecc4;
array mecd (t) mecd1 mecd2 mecd3 mecd4;
array mec (p) meca mecb mecc mecd;

array ymsca (t) ymsca1 ymsca2 ymsca3 ymsca4;
array ymscb (t) ymscb1 ymscb2 ymscb3 ymscb4;

array ymscc (t) ymscc1 ymscc2 ymscc3 ymscc4;
array ymscd (t) ymscd1 ymscd2 ymscd3 ymscd4;
array ymsc (p) ymsca ymscb ymscc ymscd;

array ymeca (t) ymeca1 ymeca2 ymeca3 ymeca4;
array ymecb (t) ymecb1 ymecb2 ymecb3 ymecb4;
array ymecc (t) ymecc1 ymecc2 ymecc3 ymecc4;
array ymecd (t) ymecd1 ymecd2 ymecd3 ymecd4;
array ymec (p) ymeca ymecb ymecc ymecd;

/*continuous start month of cohabitation*/
array csmca (t) csmca1 csmca2 csmca3 csmca4;
array csmcb (t) csmcb1 csmcb2 csmcb3 csmcb4;
array csmcc (t) csmcc1 csmcc2 csmcc3 csmcc4;
array csmcd (t) csmcd1 csmcd2 csmcd3 csmcd4;
array csmc (p) csmca csmcb csmcc csmcd;

/*continuous end month of cohabitation*/
array cemca (t) cemca1 cemca2 cemca3 cemca4;
array cemcb (t) cemcb1 cemcb2 cemcb3 cemcb4;
array cemcc (t) cemcc1 cemcc2 cemcc3 cemcc4;
array cemcd (t) cemcd1 cemcd2 cemcd3 cemcd4;
array cemc (p) cemca cemcb cemcc cemcd;

/*year and month start of Marriage*/
array ymsma (t) ymsma1 ymsma2 ymsma3 ymsma4;
array ymsmb (t) ymsmb1 ymsmb2 ymsmb3 ymsmb4;
array ymsmc (t) ymsmc1 ymsmc2 ymsmc3 ymsmc4;
array ymsmd (t) ymsmd1 ymsmd2 ymsmd3 ymsmd4;
array ymsm (p) ymsma ymsmb ymsmc ymsmd;

/* continuous start month of marriage*/
array csmma (t) csmma1 csmma2 csmma3 csmma4;
array csmmb (t) csmmb1 csmmb2 csmmb3 csmmb4;
array csmmc (t) csmmc1 csmmc2 csmmc3 csmmc4;
array csmmd (t) csmmd1 csmmd2 csmmd3 csmmd4;
array csmm (p) csmma csmmb csmmc csmmd;

/* continuous start month of separation */
array csmsa (t) csmsa1 csmsa2 csmsa3 csmsa4;
array csmsb (t) csmsb1 csmsb2 csmsb3 csmsb4;
array csmsc (t) csmsc1 csmsc2 csmsc3 csmsc4;
array csmsd (t) csmsd1 csmsd2 csmsd3 csmsd4;
array csms (p) csmsa csmsb csmsc csmsd;

/* years and month start separation*/

array ymssa (t) ymssa1 ymssa2 ymssa3 ymssa4;
array ymssb (t) ymssb1 ymssb2 ymssb3 ymssb4;
array ymssc (t) ymssc1 ymssc2 ymssc3 ymssc4;
array ymssd (t) ymssd1 ymssd2 ymssd3 ymssd4;
array ymss (p) ymssa ymssb ymssc ymssd;

/* continuous end month of marriage*/
array cemma (t) cemma1 cemma2 cemma3 cemma4;
array cemmb (t) cemmb1 cemmb2 cemmb3 cemmb4;
array cemmc (t) cemmc1 cemmc2 cemmc3 cemmc4;
array cemmd (t) cemmd1 cemmd2 cemmd3 cemmd4;
array cemm (p) cemma cemmb cemmc cemmd;

/*continuous end month of separation */
array cemsa (t) cemsa1 cemsa2 cemsa3 cemsa4;
array cemsb (t) cemsb1 cemsb2 cemsb3 cemsb4;
array cemsc (t) cemsc1 cemsc2 cemsc3 cemsc4;
array cemsd (t) cemsd1 cemsd2 cemsd3 cemsd4;
array cems (p) cemsa cemsb cemsc cemsd;

/* dummy for cohabitation continuous - since dli*/
array cdlia (t) M46701 cdlia2 cdlia3 cdlia4;
array cdlib (t) cdlib1 cdlib2 cdlib3 cdlib4;
array cdlic (t) cdlic1 cdlic2 cdlic3 cdlic4;
array cdlid (t) cdlid1 cdlid2 cdlid3 cdlid4;
array cdli (p) cdlia cdlib cdlic cdlid;

/*dummy for cohabitation continuous - since start (after dli date)*/
array cbega (t) M47001 cbega2 cbega3 cbega4;
array cbegb (t) M47002 cbegb2 cbegb3 cbegb4;
array cbegc (t) M47003 cbegc2 cbegc3 cbegc4;
array cbegd (t) cbegd1 cbegd2 cbegd3 cbegd4;
array cbeg (p) cbega cbegb cbegc cbegd;

/* cohabitation continuous - since start (after dli date)*/
array cbeg2a (t) M910011 M910012 M910013 cbeg2a4;
array cbeg2b (t) M910021 M910022 cbeg2b3 cbeg2b4;
array cbeg2c (t) cbeg2c1 cbeg2c2 cbeg2c3 cbeg2c4;
array cbeg2d (t) cbeg2d1 cbeg2d2 cbeg2d3 cbeg2d4;
array cbeg2 (p) cbeg2a cbeg2b cbeg2c cbeg2d;

/* legally married when began cohabitating*/
array mbega (t) M45001 mbega2 mbega3 mbega4;
array mbegb (t) M45002 mbegb2 mbegb3 mbegb4;
array mbegc (t) M45003 mbegc2 mbegc3 mbegc4;
array mbegd (t) mbegd1 mbegd2 mbegd3 mbegd4;
array mbeg (p) mbega mbegb mbegc mbegd;

/*marital/cohabitation status at date of last interview*/
array mdlia (t) mardli mdlia2 mdlia3 mdlia4;
array mdlib (t) mdlib1 mdlib2 mdlib3 mdlib4;
array mdlic (t) mdlic1 mdlic2 mdlic3 mdlic4;
array mdlid (t) mdlid1 mdlid2 mdlid3 mdlid4;
array mdli (p) mdlia mdlib mdlic mdlid;
/* First or next change in status.
Read "howa2" as change in marital status for partner a, period 2. */

array howa1 (t) m540011 m540012 howa13 howa14;
array howa2 (t) m7900111 how22 how23 how24;
array howb3 (t) m7900211 howb32 howb33 howb34;
array howa4 (t) m9800111 howa42 howa43 howa44;

/*collapse into how status changed*/
array how1 (p) howa1 howb1 howc1 howd1;
array how2 (p) howa2 howb2 howc2 howd2;
array how3 (p) howa3 howb3 howc3 howd3;
array how4 (p) howa4 howb4 howc4 howd4;

array how (i) how1 how2 how3 how4 ;

/*month and year change is marry*/

array hyma1 (t) M570011y hyma12 hyma13 hyma14;
array hmma1 (t) M570011m hmma12 hmma13 hmma14;

array hyma2 (t) m8200111y hyma22 hyma23 hyma24;
array hmma2 (t) m8200111m hmma22 hmma23 hmma24;

array hymb3 (t) hymb31 hymb32 hymb33 hymb34;
array hmmb3 (t) hmmb31 hmmb32 hmmb33 hmmb34;

array hyma4 (t) m10100111y hyma42 hyma43 hyma44;
array hmma4 (t) m10100111m hmma42 hmma43 hmma44;

/*Collapse into month and year change is marry*/
array hym1 (p) hyma1 hymb1 hymc1 hymd1;
array hmm1 (p) hmma1 hmmb1 hmmc1 hmmd1;
array hym2 (p) hyma2 hymb2 hymc2 hymd2;
array hmm2 (p) hmma2 hmmb2 hmmc2 hmmd2;
array hym3 (p) hyma3 hymb3 hymc3 hymd3;
array hmm3 (p) hmma3 hmmb3 hmmc3 hmmd3;
array hym4 (p) hyma4 hymb4 hymc4 hymd4;
array hmm4 (p) hmma4 hmmb4 hmmc4 hmmd4;
array hym (i) hym1 hym2 hym3 hym4;
array hmm (i) hmm1 hmm2 hmm3 hmm4;

/*month and year change=separation, divorce, annulment*/
array hyssa1 (t) M560011Y M560012Y hyssa13 hyssa14;
array hmssa1 (t) M560011M M560012M hmssa13 hmssa14;
array hyssa2 (t) M8100111Y M8100211Y hyssa23 hyssa24;
array hmssa2 (t) M8100111M M8100211M hmssa23 hmssa24;
array hyssa3 (t) hyssa31 hyssa32 hyssa33 hyssa34;
array hmssa3 (t) hmssa31 hmssa32 hmssa33 hmssa34;
array hyssa4 (t) hyssa41 hyssa42 hyssa43 hyssa44;
array hmssa4 (t) hmssa41 hmssa42 hmssa43 hmssa44;

/*collapse into month and year change=separation, divorce, annulment*/
array hyss1 (p) hyssa1 hyssb1 hyssc1 hyssd1;
array hmss1 (p) hmssa1 hmssb1 hmssc1 hmssd1;
array hyss2 (p) hyssa2 hyssb2 hyssc2 hyssd2;
array hmss2 (p) hmssa2 hmssb2 hmssc2 hmssd2;
array hyss3 (p) hyssa3 hyssb3 hyssc3 hyssd3;
array hmss3 (p) hmsas3 hmssb3 hmssc3 hmssd3;
array hyss4 (p) hyssa4 hyssb4 hyssc4 hyssd4;
array hmss4 (p) hmssa4 hmssb4 hmssc4 hmssd4;
array hyss (i) hyss1 hyss2 hyss3 hyss4;
array hmss (i) hmss1 hmss2 hmss3 hmss4;

/*Collapsed marital status*/
array cmarsa (t) cmarsa1 cmarsa2 cmarsa3 cmarsa4;
array cmarsb (t) cmarsb1 cmarsb2 cmarsb3 cmarsb4;
array cmarsc (t) cmarsc1 cmarsc2 cmarsc3 cmarsc4;
array cmarsd (t) cmarsd1 cmarsd2 cmarsd3 cmarsd4;
array cmars (p) cmarsa cmarsb cmarsc cmarsd;

/* imars individual marital status */
array imarsa (t) imarsa1 imarsa2 imarsa3 imarsa4;
array imarsb (t) imarsb1 imarsb2 imarsb3 imarsb4;
array imarsc (t) imarsc1 imarsc2 imarsc3 imarsc4;
array imarsd (t) imarsd1 imarsd2 imarsd3 imarsd4;
array imars (p) imarsa imarsb imarsc imarsd;

/*dummy set to one if start month cohabitate is invalid*/
array fixmc1 (t) fixmc11 fixmc12 fixmc13 fixmc14;
array fixmc2 (t) fixmc21 fixmc22 fixmc23 fixmc24;
array fixmc3 (t) fixmc31 fixmc32 fixmc33 fixmc34;
array fixmc4 (t) fixmc41 fixmc42 fixmc43 fixmc44;
array fixmc (p) fixmc1 fixmc2 fixmc3 fixmc4;

/*dummy set to one if start month marry is invalid*/
array fixmm1 (t) fixmm11 fixmm12 fixmm13 fixmm14;
array fixmm2 (t) fixmm21 fixmm22 fixmm23 fixmm24;
array fixmm3 (t) fixmm31 fixmm32 fixmm33 fixmm34;
array fixmm4 (t) fixmm41 fixmm42 fixmm43 fixmm44;
array fixmm (p) fixmm1 fixmm2 fixmm3 fixmm4;

/*dummy set to one if start year cohabitate is invalid*/
array fixyc1 (t) fixyc11 fixyc12 fixyc13 fixyc14;
array fixyc2 (t) fixyc21 fixyc22 fixyc23 fixyc24;
array fixyc3 (t) fixyc31 fixyc32 fixyc33 fixyc34;
array fixyc4 (t) fixyc41 fixyc42 fixyc43 fixyc44;
array fixyc (p) fixyc1 fixyc2 fixyc3 fixyc4;

/*dummy set to one if start year marry is invalid*/
array fixym1 (t) fixym11 fixym12 fixym13 fixym14;
array fixym2 (t) fixym21 fixym22 fixym23 fixym24;
array fixym3 (t) fixym31 fixym32 fixym33 fixym34;
array fixym4 (t) fixym41 fixym42 fixym43 fixym44;
array fixym (p) fixym1 fixym2 fixym3 fixym4;

array coha (t) cohaf cohas cohat cohafour;
array cohb (t) cohbf cohbs cohbt cohbfour;
array cohc (t) cohcf cohcs cohct cohcfour;
array cohd (t) cohdf cohds cohdt cohdfour;
array coh (p) coha cohb cohc cohd ;

array ma (t) maf mas mat mafour;
array mb (t) mbf mbs mbt mbfour;
array mc (t) mcf mcs mct mcfour;
array md (t) mcf mcs mdt mdfour;
array m (p) ma mb mc md;

/*number of cohabitations*/
array nuca (t) nuca1 nuca2 nuca3 nuca4;
array nucb (t) nucb1 nucb2 nucb3 nucb4;
array nucc (t) nucc1 nucc2 nucc3 nucc4;
array nucd (t) nucd1 nucd2 nucd3 nucd4;
array nuc (p) nuca nucb nucc nucd;

/*number of marriages*/
array numa (t) numa1 numa2 numa3 numa4;
array numb (t) numb1 numb2 numb3 numb4;
array numc (t) numc1 numc2 numc3 numc4;
array numd (t) numd1 numd2 numd3 numd4;
array num (p) numa numb numc numd;

/* 6-23-02 I am going to add this in R5*/
/* month and year relationship ended */
array eyra (t) M117001Y eyra2 eyra3 eyra4;
array eyrb (t) M117002Y eyrb2 eyrb3 eyrb4;
array eyrc (t) eyrc1 eyrc2 eyrc3 eyrc4;
array eyrd (t) eyrd1 eyrd2 eyrd3 eyrd4;

array emoa (t) M117001M emoa2 emoa3 emoa4;
array emob (t) M117002M emob2 emob3 emob4;
array emoc (t) emoc1 emoc2 emoc3 emoc4;
array emod (t) emod1 emod2 emod3 emod4;

/*collapse all start years and months into arrays*/
array eyr (p) eyra eyrb eyrc eyrd;
array emo (p) emoa emob emoc emod;

/* Current staus of relationship */
array fstata (t) M114001 fstata2 fstata3 fstata4;
array fstatb (t) M114002 fstatb2 fstatb3 fstatb4;
array fstatc (t) M114003 fstatc2 fstatc3 fstatc4;
array fstatd (t) fstatd1 fstatd2 fstatd3 fstatd4;

/*collapse married into array*/
array fstat (p) fstata fstatb fstatc fstatd;

do l=1 to 283;
if l=dlicm then do;
cohhr6=r6co;
end;
end;

/* set up back report case*/
if 0<p1<701 and (cohhr6=. or cohhr6=-4) then flagbackold=1;
if (flag48001=1 or flagbackold=1) then do;
do l=169 to 283;
cohhr6=max(of r6co169-r6co283);
end;
end;

/* stopping live together right after dli*/
if PUBID in (6169,7770) then cohhr6=-4;
/* back living with spouse*/
if PUBID =1386 then cohhr6=201;

do p=1 to 4; /* loop for p */
do t=1 to 4; /* loop for t */

if cdli=1 then
do;
ymsc=dliym;
end;

if cdli=0 then ymsc=dliym;
if mdli=1 or mdli=2 then cmars=0;
if mdli=3 or mdli=4 then
do;
cmars=1;

ymsm=dliym;
end;
if mdli=5 or mdli=6 then do;
cmars=2;
ymss=dliym;
end;
if mdli=7 or mdli=8 then cmars=3;
if mdli=9 or mdli=10 then cmars=4;
if mdli<0 and mdli ne -4 then cmars=mdli;

if ysc>0 and msc>0 and ysc gt bdate_y then ymsc=(ysc*100)+msc;

/* If a start year or month is missing and flag ne 1 then I'm setting it to dli. */
if (-3 le ysc le 0 or -3 le msc le 0) then ymsc=dliym;
if (-3 le ysc le 0 and -3 le msc le 0) then ymsc=dliym;

csmc=(round(ymsc,100)-198000)*.12+(ymsc-round(ymsc,100));

/* create dummies for negative answers. Any negative answer is set
to the dli and dummies (fixyc, fixmc) are created to identify these cases. */

if -3 le ysc le 0 then fixyc=1;
if -3 le msc le 0 then fixmc=1;

/* If a start year or month is missing, then I'm setting it to dli. */
/* If a start year and month are missing,then I'm setting it to dli. */
if -3 le ysc le 0 or -3 le msc le 0 then ymsc=dliym;
if -3 le ysc le 0 and -3 le msc le 0 then ymsc=dliym;
if ysc > 0 and -3 le msc le 0 then ymsc=(ysc*100)+1;/*this is new 1=jan*/

* need to add stop information for arrays;

if yec>0 and mec>0 and yec gt bdate_y then ymec=(yec*100)+mec;

if (-3 le yec le 0 or -3 le mec le 0)

and (cbeg ne 1 and cbeg2 ne 1 and cdli ne 1) then ymec=iym;

if yec>0 and -4<mec<0 then ymec=(yec*100)+12;

csmc=(round(ymsc,100)-198000)*.12+(ymsc-round(ymsc,100));
cemc=((round(ymec,100)-198000)*.12+(ymec-round(ymec,100)))-1;
if ymec=ymsc then cemc=(round(ymec,100)-198000)*.12+(ymec-round(ymec,100));
if cdli=1 or cbeg=1 then cemc=doicm;
if m910011=1 then cemca2=doicm;
if m910012=1 then cemca3=doicm;

if mbeg=1 then do;
cmars=1;
imars=1;
ymsm=ymsc;
ymsc=.;

if fixmc=1 then fixmm=1;
if fixyc=1 then fixym=1;
end;

if mbeg=0 then imars=0;
if mbeg=-4 and cmars ne . and cohhr6 gt 200 then imars=1;
else if mbeg=-4 and cmars ne . and cmars ne -4 and 100 lt cohhr6 lt 200 then imars=0;

csmm=(round(ymsm,100)-198000)*.12+(ymsm-round(ymsm,100));
csms=(round(ymss,100)-198000)*.12+(ymss-round(ymss,100));

if mardli=7 or mardli=8 then do; /*10-31-03*/
ymss=dliym;
csms=(round(ymss,100)-198000)*.12+(ymss-round(ymss,100));
end; /*10-31-03*/
if csms>0 then cems=doicm;
if csmm>0 then cemm=doicm;

do l=start to doicm; /* loop 1 */
C=C+1;
if csmc>0 and cemc>0 and csmc LE C LE cemc then cohal=1;
if csmc>0 and cemc>0 and csmc LE C LE cemc then coh=1;

if cmars=1 and csmm>0 and cemm>0 and csmm le c le cemm then mal=1;
if imars=1 and csmm>0 and cemm>0 and csmm le c le cemm then m=1;

if 2 le cmars le 3 and csms>0 and cems>0 and csms le c le cems then mal=cmars;
if 2 le imars le 3 and csms>0 and cems>0 and csms le c le cems then m=imars;
if cmars=0 then mal=cmars; /* add 7-15-02 */
if -2 le cmars le -1 then mal=cmars;
if -2 le imars le -1 then m=imars;
end; /* end loop 1 */

/* This loop 1 will help to reserve the information from last round, without this loop, the old information overwritten by the loops following. */

do i=1 to 4; /* Loop 2 */

if how=1 and hym>0 and hmm>0 then do;
cmars=1;
imars=1;
ymsm=hym*100+hmm;

end;

if -2 le how le -1 then do;
cmars=how;
imars=how;
end;

if how=1 and (-4<hym<0 or -4<hmm<0) then do;
cmars=1;
imars=1;
ymsm=iym;
end;

csmm=(round(ymsm,100)-198000)*.12+(ymsm-round(ymsm,100));

/* Marriage ends in legal separation */
if how=3 and hyss>0 and hmss>0 then do;
cmars=2;
imars=2;
ymss=(hyss*100)+hmss;

end;
/* 4-8-02 Marriage ends in divorce */
if how=4 and hyss>0 and hmss>0 then do;
cmars=3;
imars=3;
ymss=(hyss*100)+hmss;

end;
/* 4-8-02 Marriage ends in divorce */
if how=5 and hyss>0 and hmss>0 then do;
cmars=3;
imars=3;
ymss=(hyss*100)+hmss;

end;

csmm=(round(ymsm,100)-198000)*.12+(ymsm-round(ymsm,100));
csms=(round(ymss,100)-198000)*.12+(ymss-round(ymss,100));
if csms>0 then cems=doicm;
if csmm>0 then cemm=doicm;

/* YMAR-114000 (fstat in the arrays) collects current status of the relationship. */
if fstat=2 and eyr>0 and emo>0 then do;
cmars=0; /* fstat=annulment, which translates into never married in collapsed mar. status */
imars=0;
csms=(eyr-1980)*12 + emo;

end;

if fstat=2 and (-4<eyr<0 or -4<emo<0) then do;
cmars=0;
imars=0;
csms=doicm;
end;

if fstat=3 and eyr>0 and emo>0 then do;
cmars=2; /* separation */
imars=2;
csms=(eyr-1980)*12 + emo;

if how=1 and hym>0 and hmm>0 then do;
cmars=1;
imars=1;
ymsm=hym*100+hmm;
cmarsa1=1; /* added in R7 Three R's married Round 7, then legal separated several month late*/
imarsa1=1;
end;
end;

if fstat=3 and (-4<eyr<0 or -4<emo<0) then do;
cmars=2;
imars=2;
csms=doicm;

end;

if fstat=4 and eyr>0 and emo>0 then do;

cmars=3;
imars=3; /*10-31-03 divorce */
csms=(eyr-1980)*12 + emo;
/* divorce in current Round then had new partner
or had partner in current round then divorced later*/
if cemc>=start and (mardli=3 or mardli=4) and p2>700 then do; /*add in R7*/
do l=start to cemc;
maf=1;
end;
end;

end;

if fstat=4 and (-4<eyr<0 or -4<emo<0) then do;
cmars=3;
imars=3; /*10-31-03 divorce */
csms=doicm;

end;

if fstat=5 and eyr>0 and emo>0 and csmm>0 then do;
cmars=4;
imars=4; /*10-31-03 widowed */
csms=(eyr-1980)*12 + emo;
widow=1;
end;

if fstat=5 and (-4<eyr<0 or -4<emo<0) and csmm>0 then do;
cmars=4;
imars=4;
csms=doicm;
widow=1;
end;
if csms>0 then cems=doicm;/*10-31-03*/

if -4<fstat<0 then cmars=fstat;

/* Now that the start & end dates of marriages/cohabitation are created, we can place that information into the array. The information from the last week is used to create the variable for marital status and collapsed marital status. */
C=0;
do l=1 to doicm; /* loop 1 */
C=C+1;
if csmc>0 and cemc>0 and csmc LE C LE cemc then cohal=1;
if csmc>0 and cemc>0 and csmc LE C LE cemc then coh=1;

if cmars=1 and csmm>0 and cemm>0 and csmm le c le cemm then mal=1;
if imars=1 and csmm>0 and cemm>0 and csmm le c le cemm then m=1;

/*if 2 le cmars le 3 and csms>0 and cems>0 and csms le c le cems then mal=cmars;
if 2 le imars le 3 and csms>0 and cems>0 and csms le c le cems then m=imars;*/
if cmars = 2 and csms>0 and cems>0 and csms le c le cems then mal=2;/*10-31-03*/
if imars = 2 and csms>0 and cems>0 and csms le c le cems then m=2; /*10-31-03*/
if cmars = 3 and csms>0 and cems>0 and csms le c le cems then mal=3;/*10-31-03*/
if imars = 3 and csms>0 and cems>0 and csms le c le cems then m=3; /*10-31-03*/
if cmars = 4 and csms>0 and cems>0 and csms le c le cems then mal=4;/*10-31-03*/
if imars = 4 and csms>0 and cems>0 and csms le c le cems then m=4; /*10-31-03*/

if -2 le cmars le -1 then mal=cmars;
if -2 le imars le -1 then m=imars;

if cmars=0 then mal=cmars;

if c=doicm then do;
if mal in (-1,-2) then mars=-3;
if mal=0 and cohal=1 then mars=1;
if mal=0 and cohal=0 then mars=2;
if mal=1 and cohal=1 then mars=3;
if mal=1 and cohal=0 then mars=4;
if mal=2 and cohal=1 then mars=5;
if mal=2 and cohal=0 then mars=6;
if mal=3 and cohal=1 then mars=7;
if mal=3 and cohal=0 then mars=8;
if mal=4 and cohal=1 then mars=9;
if mal=4 and cohal=0 then mars=10;
marstat=mars;
end;

end;
end;/* end of loop t*/
end;/*end of loop p*/

end;/*******/

/* Create collapsed marital status from marital status.*/
if 1 le marstat le 2 then cmarstat=0;
if 3 le marstat le 4 then cmarstat=1;
if 5 le marstat le 6 then cmarstat=2;
if 7 le marstat le 8 then cmarstat=3;
if 9 le marstat le 10 then cmarstat=4;
if -2 le marstat le -1 then cmarstat=marstat;
if marstat=-3 then cmarstat=-3;

if csmca1>0 then do;
cohcm=csmca1;
end;

if csmca1>0 and csmca2>0 and csmca1<csmca2 then do;
cohcm=csmca1;
end;

if csmca1>0 and csmca2>0 and csmca1>csmca2 then do
cohcm=csmca2;
end;

if csmca1>0 and csmca1<csmcb1 then do
cohcm=csmca1;
end;

if csmcb1>0 and csmca1>csmcb1 then do
cohcm=csmcb1;
end;

if csmma1>0 then do
marcm=csmma1;
end;

if csmma1>0 and csmma2>0 and csmma1> csmma2 then do
marcm=csmma2;
end;

if csmma1>0 and csmmb1>0 and csmma1> csmmb1 then do
marcm=csmmb1;
end;
r7marcm=marcm;
r7cohcm=cohcm;

if csmma1<0 and csmmb1>0 then do;
marcm=csmmb1;
end;
r7marcm=marcm;
r7cohcm=cohcm;

/* Respondents, Round 1 c.v. for first marriage date post-dates a marriage they report in Round 2.
We need the continuous month min of these two dates. */
if dlimarcm>0 then marcm=dlimarcm;
if r7marcm>0 then marcm=r7marcm;
if dlimarcm>0 and r7marcm>0 then do;
marcm=dlimarcm;
end;
array cvcm cohcm marcm;
array cvy cohy mary;
array cvm cohm marm;

do over cvcm;
if 289 le cvcm le 295 then do;
cvy=2004;
cvm=cvcm-288;
end;

if 277 le cvcm le 288 then do;
cvy=2003;
cvm=cvcm-276;
end;

if 265 le cvcm le 276 then do;
cvy=2002;
cvm=cvcm-264;
end;

if 253 le cvcm le 264 then do;
cvy=2001;
cvm=cvcm-252;
end;

if 241 le cvcm le 252 then do;
cvy=2000;
cvm=cvcm-240;
end;
if 229 le cvcm le 240 then do;
cvy=1999;
cvm=cvcm-228;
end;
if 217 le cvcm le 228 then do;
cvy=1998;
cvm=cvcm-216;
end;
if 205 le cvcm le 216 then do;
cvy=1997;
cvm=cvcm-204;
end;
if 193 le cvcm le 204 then do;
cvy=1996;
cvm=cvcm-192;
end;
if 181 le cvcm le 192 then do;
cvy=1995;
cvm=cvcm-180;
end;
if 169 le cvcm le 180 then do;
cvy=1994;
cvm=cvcm-168;
end;
if 157 le cvcm le 168 then do;
cvy=1993;
cvm=cvcm-156;
end;
if cvcm=. then do;
cvcm=-4;
cvy=-4;
cvm=-4;
end;
end;

/*To correct for those who don't know the start month for cohabiting*/
if -4<m31001m<0 and m31001y>0 then do;
cohy=m31001y;
cohm=-3;
cohcm=-3;
end;

/*To correct for those who don't know the start year and month for cohabiting*/
if -4<m31001m<0 and -4<m31001y<0 and prvcohcm=-4 then do;
cohm=-3;
cohcm=-3;
cohy=-3;
end;
if (-4<m31001m<0 and -4<m31001y<0) and (m31002y>0 and m31002y>0 ) and prvcohcm=-4 then do;
cohm=-3;
cohcm=-3;
cohy=-3;
end;

if ((-4<m31002m<0 and -4<m31002y<0) or (-4<m700011y<0 and -4<m700011m<0))
and (m31001y>0 and m31001y>0 ) then do;
cohm=m31001m;
cohcm=csmca1;
cohy=m31001y;
end;

if m45001=1 and -4<m31001m<0 and -4<m31001y<0 then do; /* need to prove in R8*/
cohm=-4;
cohcm=-4;
cohy=-4;
marcm=-3;
mary=-3;
marm=-3;
end;

/*If old date present and don't deny then use old date*/
if prevcohm ne -4 then do;
cohcm= prvcohcm;
cohy=prevcohy;
cohm= prevcohm;
end;

if prevmarm ne -4 then do;
marcm=prvmarcm;
mary=prevmary;
marm=prevmarm;
end;

if prevcohm =-4 and prevmarm>0 and (m31001y=-4 or m31002y=-4) then do;
cohcm= -4;
cohy=-4;
cohm= -4;
end;

if prevcohm =-4 and prevmarm>0 and (m31001y>-4 or m31002y>-4) then do;
cohcm=csmca1;
cohy=m31001y;
cohm=m31001m;
end;

if prevcohm =-3 then do ;
cohcm= prvcohcm;
cohy= prevcohy;
cohm= prevcohm;
end;

if prevcohm =-3 and m31001y>0 and m31001m>0 then do;
cohcm= csmca1;
cohy=m31001y;
cohm= m31001m;
end;

if prevcohm =-4 and m31001y=-4 and m31002y=-4 and m31003y=-4 then do ;
cohcm= prvcohcm;
cohy= prevcohy;
cohm= prevcohm;
end;

if prevmarm=-3 then do;
marcm=prvmarcm;
mary=prevmary;
marm=prevmarm;
end;

if prevmarm=-3 and m8200111y>0 and m8200111m>0 then do;
marcm=csmma1;
mary=m8200111y;
marm=m8200111m;
end;


/*Marital status for event history*/
do l=start to doicm;
if -2 le mal le -1 then mars=-3;
if mal=0 and cohal=1 then mars=1;
if mal=0 and cohal=0 then mars=0;
if mal=1 and cohal=1 then mars=2;
if mal=1 and cohal=0 then mars=2;
if mal=2 and cohal=1 then mars=3;
if mal=2 and cohal=0 then mars=3;
if mal=3 and cohal=1 then mars=4;
if mal=3 and cohal=0 then mars=4;
if mal=4 and cohal=1 then mars=5;
if mal=4 and cohal=0 then mars=5;
end;

*For the documentation except the marital status;

do l=start to doicm;
if cohaf=1 or cohas=1 or cohat=1 or cohafour=1 then cohaa=1;
if cohbf=1 or cohbs=1 or cohbt=1 or cohbfour=1 then cohbb=1;
if cohcf=1 or cohcs=1 or cohct=1 or cohcfour=1 then cohcc=1;
if cohdf=1 or cohds=1 or cohdt=1 or cohdfour=1 then cohdd=1;
if maf=1 or mas=1 or mat=1 or mafour=1 then maa=1;
if mbf=1 or mbs=1 or mbt=1 or mbfour=1 then mbb=1;
if mcf=1 or mcs=1 or mct=1 or mcfour=1 then mcc=1;
if mdf=1 or mds=1 or mdt=1 or mdfour=1 then mdd=1;
end;
/* Mar-Cohabitation;*/
do l=start to doicm;
if cohdd=1 then cohh=104;
if cohcc=1 then cohh=103;
if cohbb=1 then cohh=102;
if cohaa=1 then cohh=101;

if mdd=1 then cohh=204;
if mcc=1 then cohh=203;
if mbb=1 then cohh=202;
if maa=1 then cohh=201;

end;

/* Mar_Dual */
do l=start to doicm;
if cohh>0 and cohh ne 204 and cohh ne 104 and cohdd=1 then dual=104;
if cohh>0 and cohh ne 204 and cohh ne 104 and mdd=1 then dual=204;

if cohh>0 and cohh ne 203 and cohh ne 103 and cohcc=1 then dual=103;
if cohh>0 and cohh ne 203 and cohh ne 103 and mcc=1 then dual=203;

if cohh>0 and cohh ne 202 and cohh ne 102 and cohbb=1 then dual=102;
if cohh>0 and cohh ne 202 and cohh ne 102 and mbb=1 then dual=202;
end;

*Mar_Partner_Link;
do l=1 to doicm;

if cohcc=1 or mcc=1 then link=p3;
if cohbb=1 or mbb=1 then link=p2;
if cohaa=1 or maa=1 then link=p1;
end;

if doicm=-5 then do;
do l=start to doicm;
mars=-4;
cohh=-4;
dual=-4;
link=-4;
end;
end;

/* Find the number of partners and spouses in r6;*/
do l=169 to 283;
if 100 lt r6co lt 200 then r6pt=r6co-100;
if r6co gt 200 then r6sp=r6co-200;
end;

nump6=max(of r6pt169-r6pt283);
nums6=max(of r6sp169-r6sp283);

if nump6=. then nump6=0;/*11-7-03*/
if nums6=. then nums6=0;/*11-7-03*/

numr6=max(nump6,nums6);


/* Add the partners and spouses from round 1 round 2 round 3 and round4 and round 5*/
do l=start to 295;
if cohh>0 and numr6>=0 then cohh=cohh+numr6;/*6-20-04*/
/*if cohh>0 and 100<cohh<200 then cohh=cohh+nump6;/*11-7-03*/
/*if cohh>0 and cohh>200 then cohh=cohh+nums6; /*11-7-03*/
if dual>0 and numr6>0 then dual=dual+numr6;
end;


*Find the number of partners and spouses in round 7;
do l=start to 295;
if 100 lt cohh lt 200 then r7pt=cohh-100;
if cohh gt 200 then r7sp=cohh-200;
end;

/* If the respondent cohabited with the partner or spouse from last interview,
do the following change;*/
if 100 lt cohhr6 lt 200 and (flagp1=1 or flagp2=1 or flagp3=1)
then do;
do l=start to doicm;
if 100 lt cohh lt 200 and r7pt=min(of r7pt169-r7pt295) then cohh=cohhr6;
else if 100 lt cohh lt 200 then cohh=cohh-1;
if cohh gt 200 and r7sp=min(of r7sp169-r7sp295) then cohh=200+(cohhr6-100);
else if cohh gt 200 then cohh=cohh-1;
if 100 lt dual lt 200 and r7pt=min(of r7pt169-r7pt295) then dual=cohhr6;
else if 100 lt dual lt 200 then cohh=dual-1;
if dual gt 200 and r7sp=min(of r7pt169-r7pt295) then dual=200+(cohhr6-100);
else if dual gt 200 then dual=dual-1;
end;
end;

if cohhr6>200 and (flagp1=1 or flagp2=1 or flagp3=1)
then do;
do l=start to doicm;
if cohh gt 200 and r7sp=min(of r7sp169-r7sp295) then cohh=cohhr6;
else if cohh gt 200 then cohh=cohh-1;
if 100 lt cohh lt 200 and r7pt=min(of r7sp169-r7sp295) then cohh=100+(cohhr6-200);
else if 100 lt cohh lt 200 then cohh=cohh-1;
if dual gt 200 and dual=min(of r7sp169-r7sp295)+200 then dual=cohhr6;
else if dual gt 200 then dual=dual-1;
if 100 lt dual lt 200 and dual=min(of r7sp169-r7sp295)+100 then dual=100+(cohhr6-200);
else if 100 lt dual lt 200 then dual=dual-1;
end;
end;
do l =start to doicm;
if dual=101 or dual=102 or dual=103 or dual=104 then r7dual=1;
else if cohh=101 and r7dual ne 1 then r7dual=0;
else if cohh=102 and r7dual ne 1 then r7dual=0;
else if cohh=103 and r7dual ne 1 then r7dual=0;
else if cohh=104 and r7dual ne 1 then r7dual=0;
else if cohh=201 and r7dual ne 1 then r7dual=0;
else if cohh=202 and r7dual ne 1 then r7dual=0;
else if cohh=203 and r7dual ne 1 then r7dual=0;
else if cohh=204 and r7dual ne 1 then r7dual=0;
else if r7dual ne 1 and r7dual ne 0 then r7dual=-4;
end;
if r7dual=. then r7dual=-4;

*Find the number of partner and spouses in round 7;
do l=start to doicm;
if 100 lt cohh lt 200 then r7pt=cohh-100;
if cohh gt 200 then r7sp=cohh-200;
end;

/*10-6-03 pick up max number of total mar and total cohh*/

nump7=max(of r7pt169-r7pt295);
nums7=max(of r7sp169-r7sp295);
numr7=max(nump7,nums7);
coh_ttl=nump7;
mar_ttl=nums7;

/* no new partner in R7, to find maximum total cohabition number*/
if int_y ne -5 and (coh_ttl=. and precoh_ttl>=0 )then coh_ttl=precoh_ttl;
if coh_ttl=. then coh_ttl=0;
if 0<coh_ttl<precoh_ttl then coh_ttl=precoh_ttl;


/* no new spouse in R7. to find maximum total marriage number*/
if int_y ne -5 and (mar_ttl<premar_ttl or mar_ttl=.) and premar_ttl>=0
then mar_ttl=premar_ttl;
if marcm>0 and mar_ttl=0 then mar_ttl=1;
if mar_ttl=. and mary=-4 then mar_ttl=0;

/* for R's first time cohh and married at same time*/
if( m45001=1 or m45002=1 )and Mar_ttl>0
and (precoh_ttl<=0)then coh_ttl=0;
if (m45001=1 or m45002=1) and Mar_ttl>0 and coh_ttl=0 and prvcohcm<0 then do;
cohcm=-4;
cohy=-4;
cohm=-4;
end;

if (m45001=1 or prevmsta =4 or prevmsta =3 ) and m48001m>0 and m48001y>0 and m700011y =-4
and p2=-4 and (m540011=-4 and m540012=-4) and (m114001<=1 or m114001=6)
then flagm=1;
if flagm=1 then do;
endm=(m48001y*100)+m48001m;
cendm=((round(endm,100)-198000)*.12+(endm-round(endm,100)))-1;
end;
if flagm=1 and m31001y>0 and m31001y=m48001y and m31001m=m48001m and m700011y =-4
and p2=-4 and m540011=1 and (m540011=-4 and m540012=-4) and m114001<=1
then flagmm=1;
if flagmm=1 then do;
endm=(m48001y*100)+m48001m;
cendm=((round(endm,100)-198000)*.12+(endm-round(endm,100)));
end;


if (m45001=1 or prevmsta =4 or prevmsta =3 ) and m920011m>0 and m920011y>0 and m700011y =-4
and p2=-4 and (m540011=-4 and m540012=-4) and m114001<=1
then flagm1=1;
if flagm1=1 then do;
endm1=(m920011y*100)+m920011m;
cendm1=((round(endm1,100)-198000)*.12+(endm1-round(endm1,100)))-1;
end;
do l=169 to doicm;
if (flagm=1 or flagmm=1 or flagm1=1 ) and l>cendm and m47002 ne 1 then cohh=.;
end;

if (m45001=1 or prevmsta =4 or prevmsta =3) and m48001m>-4 and m48001y>-4 and m700011y>-4
and p2=-4 and (m540011=-4 and m540012=-4) and (m114001<=1 or m114001=6)
then flagn=1;
if flagn=1 then do;
endm=(m48001y*100)+m48001m;
cendm=((round(endm,100)-198000)*.12+(endm-round(endm,100)))-1;
end;
if flagn=1 and m31001y>0 and m31001y=m48001y and m31001m=m48001m and m700011y >-4
and p2=-4 and (m540011=-4 and m540012=-4) and m114001<=1
then flagnn=1;
if flagnn=1 then do;
endm=(m48001y*100)+m48001m;
cendm=((round(endm,100)-198000)*.12+(endm-round(endm,100)));
end;

if (m45001=1 or prevmsta =4 or prevmsta =3) and m920011m>0 and m920011y>0 and m700011y >-4
and p2=-4 and (m540011=-4 and m540012=-4) and m114001<=1
then flagn1=1;

if flagn1=1 then do;
endm1=(m920011y*100)+m920011m;
cendm1=((round(endm1,100)-198000)*.12+(endm1-round(endm1,100)))-1;
end;
do l=169 to doicm;
if (flagn=1 or flagnn=1 or flagn1=1 ) and cendm<l<csmca2 then cohh=.;
if ((flagn=1 or flagnn=1 or flagn1=1 ) and csmca3>0) and cemca2<l<csmca3 then cohh=.;
if (flagn=1 or flagnn=1 or flagn1=1 ) and 0<cendm1<l then cohh=.; /*add in R7*/
end;

if (prevmsta =4 or prevmsta =3 or (m45001=1 and p1<700)) and (m48001y>-4 or m48002y>-4 or m48003y>-4) and
(m540011>-4 or m540012>-4 or m540021>-4 or m114001>1 or m114001>1 )and m114001 ne 6 then flagsp=1;
if (prevmsta=3 or prevmsta=4) and p1>0 and (m46701=0 or m46701=-4) and m31001y>-4 then flagsp1=1;

linkr6=min(of link169-link283);
do l=start to doicm;
if (flagsp=1 or flagsp1=1) and mars<2 then mars=2;
if flagsp=1 and cemca1<=l<csmsa1 and p2<700 then do;
link=linkr6;
if linkr6=. then link=p1r6;
end;
if flagsp=1 and p2=-4 and 0<cohh<cohhr6 then cohh=cohhr6;
/*if flagsp=1 and p2=-4 and m45001=1 and cohhr6<201 then cohh=201; */
end;

/*There are no spouse's name in R6 partner roster. I checked with frank. He thought that those people mass up the questions. They separated and not just break up. In r7 they back live together*/
/*Back report marriage data before dli never report before. m45001=1 very short marriage */

/* Married before dli. Reporting stopping cohabiting day before dli. Report Cohabiting with new partner in R6*/

/* legal separation in R3*/

/* Do not have stopping data in R6 and R5. Back live with R5 partner again*/

/* Hand edit those cases who married and report stopping day or separation day before or at dli
They are old partner. So I think It's better to keep track their state*/

/*To correct total number marriage 202 if it is first marriage. It should 201*/
if prevmsta<3 and (m8200111y>-4 or m570011y>-4 or m45001=1 or m45002=1 or M9800111=1) then do;/*4-10-04*/
do l=start to doicm;
if cohh>201 and premar_ttl<=0 then do;
cohh=201;
mar_ttl=1;
end;
end;
end;

if prevmsta>=3 and 0<p1<701 and p2=-4 then do;
do l=start to doicm;
if cohh>201 then do;
cohh=cohhr6;
mar_ttl=premar_ttl;
end;
end;
end;

if precoh_ttl=0 and coh_ttl=2 and( 0<p1<701 and p2=-4 or 0<p1<701 and p2>=701 or P1>=701 and p2=-4)then do;
do l=start to doicm;
if 0<cohh<201 then do;
cohh=cohh-1;
end;
end;
coh_ttl=coh_ttl-1;
end;

/* To correct stop cohabitation data at dli*/
if precoh_ttl=coh_ttl and (0<p1<701 and p2>=701) then do;
coh_ttl=coh_ttl+1;
do l=start to doicm;
if 0<cohh<200 then do;
cohh=cohh+1;
end;
end;
end;

/*Divorced at dli*/

/* to correct these people stopping data at dli*/

/** There are 16 responds who married before dli. There are no spose's name in R6 partner
roster. check with frank. He thought that those people mass up the questions. They separated
and not just break up. */

/* 7-9-04 for first time went into marriage section,martial status in event history
should start at the month of 14 birthday*/

/*do l=b14cm to doicm;
if mars=-4 and marstat ne -5 then flagmis=1;
if flagmis=1 and mars=-4 then mars=0;
end; do it late 9-22-04*/

/* back report case and do not know the data of stopping cohabitation*/
if PUBID in (4462,1513) then do;
do l=doicm;
cohh=.;
end;
end;

if PUBID=1705 then do;
do l=286 to doicm;
cohh=104;
link=701;
r7dual=0;
end;
end;

/* Two partners married with partner#2, but live partner #1*/
if PUBID= 7877 then do;
do l=281 to doicm;
cohh=103;
coh_ttl=3;
end;
end;

/* In R7 report second marriage. But There is no divorce data for first marriage */
if PUBID=4258 then do;
do l=277 to 284 ;
mars=-3;

end;
end;

/*In R5 reported marriage and cohabitation at same month. But no data. Then reported
first Marriage data. In R7 report second marriage. But There is no divorce data for first marriage */
if PUBID= 8556 then do;
do l=278 to 278;
mars=-3;
marcm=238;
mary=1999;
marm=10;
end;
end;

if PUBID=5587 then do;
do l=256 to 274;
cohh=201;
end;
do l=285 to 291 ;
cohh=202;
mar_ttl=2;
coh_ttl=precoh_ttl;
end;
end;

/* stop cohabitation before at dli. then divorce and had new partner*/
if PUBID =5856 then do;
do l=265 to 267;
link=301;
end;
end;

if PUBID = 6039 then do;
do l=start;
cohh=201;
end;
end;

if PUBID= 1362 then do;
do l=284 to 285;
cohh=.;
end;
end;

/* Comments PUBID =5901
R sd she was in another country living with her partner
for 7 months ountry and just came back to US in October.
They are not living together currently but are still together.
R and B.H. are legally married in other country not the US*/

if PUBID=5901 then do;
mar_ttl=1;
marm=-3;
mary=-3;
marcm=-3;
do l=278 ;
mars=2;
cohh=201;
end;
end;
/* married before, then married with another partner in R7*/
if PUBID =4255 then do;
do l=282 to doicm;
cohh=202;
end;
mar_ttl=2;
end;

if PUBID=8891 then do;
do l=278 to 285;
mars=3;
end;
end;
/* widowed */
if PUBID=5231 then do;
do l=start to doicm;
mars=5;
end;
marstat=10;
cmarstat=4;
end;

/* Married in previous round, but partner are not in partner Roster. Since they are not legal separated
Or legal divorce. so the have to have partner link */
do l=start to doicm;
if PUBID in

(193,
3430,
4276,
4353,
5775,
7464,
7770,
7839,
7918) then do;
link=p1r6;
if p1r6<0 and p1r5<0 then link=p1r4;
end;
end;

/*Report have partner before dli then stop cohabiting before dli*/
if PUBID in

(4594,
5558,
8162,
8337,
8719) then do;
cohm=-4;
cohy=-4;
cohcm=-4;
end;

/*Report have partner before dli. then married after dli */
if PUBID in
(387,
583,
925,
2990,
4622,
5313,
5363,
6761,
7377,
7889,
8609) then do;
coh_ttl=1;
end;

/* Cohabiting, married, stop living together,legeal separation or divoce at same Round*/
if PUBID in(6575,5109,6786,1419,3620,8951 ) then do;
start1=cemca1+1;
do l=start1 to doicm;
cohh=-4;
end;
end;
/* cohabiting, married, stop living together, legal separation or divoce at same Round m45001=1*/
if PUBID in(3620,5109,6786,8951) then do;
start2=csmca1;
end2=csmsa1-1;
do l=start2 to doicm;
if mars<3 then mars=2;
if 0<cohh<201 then cohh=201;
end;
do l=start2 to end2;
if (link=-4 or link=.) then link=p1;
end;
end;

/* 7-9-04 for first time went into marriage section, martial status in event history
should start at the month of 14 birthday*/

/*b14cm=(bdate_y+14-1980)*12+bdate_m;
if doicm>0 then do;
do l=b14cm to doicm;
if (mars=-4 or mars=.) and marstat ne -5 then flagmis=1;
if flagmis=1 and mars=-4 then mars=0;
end;
end;*/

do l=169 to dlicm;
mars=-4;
link=-4;
cohh=-4;
end;

do l= start to doicm;
if mars=. then mars=-4;
if link=. then link=-4;
if cohh=. then cohh=-4;
end;

if doicm=-5 then do;
marstat=-5;
cmarstat=-5;
cohcm=-5;
cohm=-5;
cohy=-5;
marcm=-5;
mary=-5;
marm=-5;
coh_ttl=-5;
mar_ttl=-5;
r7dual=-5;
end;

endsas;

Return to top


Youth's Fertility and Child Status

Variables Created:

  1. month and year of birth of youth's first (second, third) child <actual time>:
    CV_CHILD_BIRTH_DATE.xx_M CV_CHILD_BIRTH_DATE.xx_Y
  2. month of birth of youth's first (second, third) child <continuous month scheme>:
    CV_CHILD_BIRTH_MONTH.xx
  3. month and year of death of youth's bio-children:
    CV_CHILD_DEATH_DATE_.xxM CV_CHILD_DEATH_DATE.xx_Y
  4. month of death of youth's bio-children <continuous month scheme>:
    CV_CHILD_DEATH_MONTH.xx
  5. status of youth's first (second, third, fourth) child: CV_CHILD_STATUS.xx
  6. number of children ever born (biological, not adopted) to the youth as of the survey date
    and residing in the household: CV_BIO_CHILD_HH
  7. number of children ever born (biological, not adopted) to the youth as of the survey date
    not residing in the household: CV_BIO_CHILD_NR

Variables Used

Name in Program

Question Name on CD

 

Name in Program

Question Name on CD

CV01 CV_CHILD_BIRTH_MONTH_01_2002   BD02 BIOADOPTCHILD_BDATE_02_D_2003
CV02 CV_CHILD_BIRTH_MONTH_02_2002   BM02 BIOADOPTCHILD_BDATE_02_M_2003
CV03 CV_CHILD_BIRTH_MONTH_03_2002   BY02 BIOADOPTCHILD_BDATE_02_Y_2003
CV04 CV_CHILD_BIRTH_MONTH_04_2002   BD03 BIOADOPTCHILD_BDATE_03_D_2003
CV05 CV_CHILD_BIRTH_MONTH_05_2002   BM03 BIOADOPTCHILD_BDATE_03_M_2003
CV06 CV_CHILD_BIRTH_MONTH_06_2002   BY03 BIOADOPTCHILD_BDATE_03_Y_2003
 DATE1MR6 CV_CHILD_DEATH_DATE_01_M_2002   BD04 BIOADOPTCHILD_BDATE_04_D_2003
 DATE1YR6 CV_CHILD_DEATH_DATE_01_Y_2002   BM04 BIOADOPTCHILD_BDATE_04_M_2003
 MONTH1R6 CV_CHILD_DEATH_MONTH_01_2002   BY04 BIOADOPTCHILD_BDATE_04_Y_2003
STAT1R6 CV_CHILD_STATUS_01_2002   BD05 BIOADOPTCHILD_BDATE_05_D_2003
STAT2R6 CV_CHILD_STATUS_02_2002   BM05 BIOADOPTCHILD_BDATE_05_M_2003
STAT3R6 CV_CHILD_STATUS_03_2002   BY05 BIOADOPTCHILD_BDATE_05_Y_2003
STAT4R6 CV_CHILD_STATUS_04_2002   BD06 BIOADOPTCHILD_BDATE_06_D_2003
STAT5R6 CV_CHILD_STATUS_05_2002   BM06 BIOADOPTCHILD_BDATE_06_M_2003
STAT5R6 CV_CHILD_STATUS_06_2002   BY06 BIOADOPTCHILD_BDATE_06_Y_2003
 status1 YFER_1850_01_2003   DEAD02 BIOADOPTCHILD_DEAD_02_2003
 status2 YFER_1850_02_2003   DEAD03 BIOADOPTCHILD_DEAD_03_2003
 status3 YFER_1850_03_2003   DEAD04 BIOADOPTCHILD_DEAD_04_2003
 status4 YFER_1850_04_2003   DEAD05 BIOADOPTCHILD_DEAD_05_2003
 status5 YFER_1850_05_2003   DEAD06 BIOADOPTCHILD_DEAD_05_2003
 status6 YFER_1850_05_2003   dm01 BIOADOPTCHILD_DOD_01_M_2003
 f4830_1 YFER_4830_01_2003   dy01 BIOADOPTCHILD_DOD_01_Y_2003
 f4830_2 YFER_4830_02_2003   dm02 BIOADOPTCHILD_DOD_02_M_2003
 f5900_1 YFER_5900_01_2003   dy02 BIOADOPTCHILD_DOD_02_Y_2003
 f5900_2 YFER_5900_02_2003   dm03 BIOADOPTCHILD_DOD_03_M_2003
adopt1 YFER_5850_01_2003   dy03 BIOADOPTCHILD_DOD_03_Y_2003
adopt2 YFER_5850_02_2003    bioid01 BIOADOPTCHILD_ID_01_2003
 YFER12001 YFER_1200_01_2003    bioid02 BIOADOPTCHILD_ID_02_2003
 YFER12002 YFER_1200_02_2003    bioid03 BIOADOPTCHILD_ID_03_2003
 YFER12003 YFER_1200_03_2003    bioid04 BIOADOPTCHILD_ID_04_2003
 YFER12004 YFER_1200_04_2003    bioid05 BIOADOPTCHILD_ID_05_2003
 YFER12005 YFER_1200_05_2003    bioid06 BIOADOPTCHILD_ID_05_2003
 YFER12005 YFER_1200_06_2003   RESIDE01 BIOADOPTCHILD_RESIDE_01_2003
 YFER13001D YFER_1300_01_D_2003   RESIDE02 BIOADOPTCHILD_RESIDE_02_2003
 YFER13001M YFER_1300_01_M_2003   RESIDE03 BIOADOPTCHILD_RESIDE_03_2003
 YFER13001Y YFER_1300_01_Y_2003   RESIDE04 BIOADOPTCHILD_RESIDE_04_2003
 YFER13002D YFER_1300_02_D_2003   RESIDE05 BIOADOPTCHILD_RESIDE_05_2003
 YFER13002M YFER_1300_02_M_2003   RESIDE06 BIOADOPTCHILD_RESIDE_06_2003
 YFER13002Y YFER_1300_02_Y_2003    biouid01 BIOADOPTCHILD_UID_01_2003
adopt1 YFER_5850_01_2003    biouid02 BIOADOPTCHILD_UID_02_2003
adopt2 YFER_5850_02_2003    biouid03 BIOADOPTCHILD_UID_03_2003
adopt3 YFER_5850_03_2003    biouid04 BIOADOPTCHILD_UID_04_2003
adopt4 YFER_5850_04_2003    biouid05 BIOADOPTCHILD_UID_05_2003
BD01 BIOADOPTCHILD_BDATE_01_D_2003    biouid06 BIOADOPTCHILD_UID_06_2003
BM01 BIOADOPTCHILD_BDATE_01_M_2003   norcid NORCID_2003
BY01 BIOADOPTCHILD_BDATE_01_Y_2003      

Codes for Created Variables

Date of birth and death variables: Date variables are presented as both the actual month and year and the month number in a continuous month scheme.

Status variables

1 Adopted
2 Deceased
3 Non-resident, foster care
4 Non-resident, not adopted or in foster care
5 Resident

This program creates a number of variables describing the youth's fertility and the current status of the youth's children.  For more information on the continuous month system, see appendix 7 in this document.


/* first, create a variable indicating the bmonth(i), birth month, and byear(i), birth year,
for each biological child. This part I use variable from roster: BIOADOPT, which is the "clean"
roster for all bio children */

array bmonth(6) bm01-bm06;
array byear (6) by01-by06;
/* talk to Rosella, R's are too young to have children, we give these children birthdate as -3;*/
if PUBID=7849 then do;
BY01=-3;
BM01=-3;
mob01=-3;
BY02=-3;
BM02=-3;
mob02=-3;
BY03=-3;
BM03=-3;
mob03=-3;
end;

/* second, create a continuous month scheme variable for the month of birth of the children
using the formula: (12*(byear(i)-1980)+bmonth(i)) */

array mob(6) mob1-mob6;

do i=1 to 6;
mob(i)=-4;
if bmonth(i) gt 0 then mob(i)=12*(byear(i)-1980)+bmonth(i);
if bmonth(i) = -2 or bmonth(i) =-1 then bmonth(i) =-3; /*2-23-04 added*/
if byear(i) = -2 or bmonth(i) =-1 then byear(i)=-3; /*2-23-04 added*/
if bmonth(i) = -3 or byear(i)=-3 then mob(i)=-3;
if bmonth(i) = -5 then mob(i)=-5;
end;

/* third, create an actual date variable for the date of death of the youth's children */

dm04=-4;
dm05=-4;
dm06=-4;
dy04=-4;
dy05=-4;
dy06=-4;

array dmonth[6] dm01-dm03 dm04 dm05 dm06;
array dyear[6] dy01-dy03 dy04 dy05 dy06;
array dead[6] dead01-dead06;
array reside[6] reside01-reside06;

/* fourth, create a continuous month scheme variable for the month of death of the children
using the formula: (12*(dody(i)-1980)+dodm(i)) */

array mod[6] mod1-mod6;

do i=1 to 6;
if dmonth(i)=-4 then mod(i)=-4;
if dmonth(i) gt 0 and dyear(i) ge 1980 then mod(i)=12*(dyear(i)-1980)+dmonth(i);
if dmonth(i)=-3 then mod(i)=-3;
if dmonth(i)=-5 then mod(i)=-5;
end;

/* fifth, create a variable indicating the status of youth's first (second, third) child:
1. Adopted
2. Deceased
3. Non-resident,foster care
4. Non-residen, not adopted out or in foster care
5. Resident */
/* It's same child*/
if PUBID=2632 then f4830_1=621;
/* same child checked , but differetn ID */

if PUBID=234 then status2=-4;
/* delete extra status */
if PUBID in (6670, 7495) then status2=-4;
if PUBID=7814 then status3=-4;
/* child gave up for adoption*/
if PUBID =7814 then status3=3;
if PUBID =5494 then status1=3;

/*update status for newly found children*/
if f4830_1>0 then do;
if f4830_1=bioid01 then status1=f5900_1;
else if f4830_1=bioid02 then status2=f5900_1;
else if f4830_1=bioid03 then status3=f5900_1;
else if f4830_1=bioid04 then status4=f5900_1;
else if f4830_1=bioid05 then status5=f5900_1;
else if f4830_1=bioid06 then status5=f5900_1;
end;

if f4830_2>0 then do;
if f4830_2=bioid01 then status1=f5900_2;
else if f4830_2=bioid02 then status2=f5900_2;
else if f4830_2=bioid03 then status3=f5900_2;
else if f4830_2=bioid04 then status4=f5900_2;
else if f4830_2=bioid05 then status5=f5900_2;
else if f4830_2=bioid06 then status6=f5900_2;
end;

if f4830_3>0 then do;
if f4830_3=bioid01 then status1=f5900_3;
else if f4830_3=bioid02 then status2=f5900_3;
else if f4830_3=bioid03 then status3=f5900_3;
else if f4830_3=bioid04 then status4=f5900_3;
else if f4830_3=bioid05 then status5=f5900_3;
else if f4830_3=bioid06 then status6=f5900_3;
end;
if f4830_4>0 then do;
if f4830_4=bioid01 then status1=f5900_4;
else if f4830_4=bioid02 then status2=f5900_4;
else if f4830_4=bioid03 then status3=f5900_4;
else if f4830_4=bioid04 then status4=f5900_4;
else if f4830_4=bioid05 then status5=f5900_4;
else if f4830_4=bioid06 then status6=f5900_4;
end;

array status[6] status1-status6;
array stat_n[6] stat_n1-stat_n6;

do i=1 to 6;
if status(i)=-4 and mob(i)>-4 then status(i)=9999;/*2-17 changed from mob>0 to mob>-4*/
end;

do i=1 to 6;
if status(i)=1 then stat_n(i)=5;
else if status(i)=2 then stat_n(i)=4;
else if status(i)=3 then stat_n(i)=1;
else if status(i)=4 then stat_n(i)=3;
else if status(i)=5 then stat_n(i)=4;
else if status(i)=6 then stat_n(i)=5;
else if status(i)=7 then stat_n(i)=5;
else if status(i)=8 then stat_n(i)=4;
else if status(i)=9 then stat_n(i)=2;
else if status(i)=10 then stat_n(i)=-3;
else if status(i)=11 then stat_n(i)=4; /*2-23-04 changed from 3 to 4*/
else if status(i)=12 then stat_n(i)=4;
else if status(i)=9999 then stat_n(i)=-16;
else if status(i)=-1 or status(i)=-2 or status(i)=-3 then stat_n(i)=-3;
else if status(i)=-4 then stat_n(i)=-4;
else if status(i)=-5 then stat_n(i)=-5;

end;

/* correct wrong status including those who died and those who were adopted out in previous rounds */
flagdeath=0;
array bioid (6) bioid01-bioid06;
do i=1 to 6;
if dmonth(i) gt -4 or dead(i)=1 then do;
stat_n(i)=2;
flagdeath=1;
end;
end;

/* added 2-10-05 for adopt out child*/
do i=1 to 6;
if stat_n(i)=-16 and cvsta1R6=1 then stat_n(i)=1;
else if stat_n(i)=-16 and cvsta2R6=1 then stat_n(i)=1;
else if stat_n(i)=-16 and cvsta3R6=1 then stat_n(i)=1;

if stat_n(i)=-16 and cvsta1R6=-5 and cvsta1R5=1 then stat_n(i)=1;
else if stat_n(i)=-16 and cvsta2R5=1 then stat_n(i)= 1;
else if stat_n(i)=-16 and cvsta1R6=-5 and cvsta1R5=-5 and cvsta1R4=1 then stat_n(i)=1;
else if stat_n(i)=-16 and cvsta1R6=-5 and cvsta1R5=-5 and cvsta2R4=1 then stat_n(i)=1;

else if stat_n(i)=-16 and cvsta1R6=-5 and cvsta1R5=-5 and cvsta1R4=-5 and cvsta1R3=1 then stat_n(i)=1;
else if stat_n(i)=-16 and cvsta1R6=-5 and cvsta1R5=-5 and cvsta2R4=-5 and cvsta2R3=1 then stat_n(i)=1;

else if stat_n(i)=-16 and cvsta1R6=-5 and cvsta1R5=-5 and cvsta2R4=-5 and cvsta2R3=-5 and cvsta1R2=1 then stat_n(i)=1;
else if stat_n(i)=-16 and cvsta1R6=-5 and cvsta1R5=-5 and cvsta2R4=-5 and cvsta2R3=-5 and cvsta2R2=1 then stat_n(i)=1;

else if stat_n(i)=-16 and cvsta1R6=-5 and cvsta1R5=-5 and cvsta2R4=-5 and cvsta2R3=-5 and cvsta2R2=-5 and cvsta1R1=1 then stat_n(i)=1;
else if stat_n(i)=-16 and cvsta1R6=-5 and cvsta1R5=-5 and cvsta2R4=-5 and cvsta2R3=-5 and cvsta2R2=-5 and cvsta2R1=1 then stat_n(i)=1;
end;

/*2-21-05 The roster information in the data set does not match the roster shown to the respondents.
In 22 cases, the number of children on the roster for the respondent was fewer than the one in the data set.
We can't get information on children that are in our roster but not in the respondent's roster.
After discussions with Rosella and Frank Bell, we decided to code all the created variables -3 for these children.*/
/*1055742 1064462 1113032 1338002 1365462 1366051 1367131 1494672 1582742
1616152 1636101 1639371 1666041 1705341 1722991 1763591 1855061 1875011
1886532 1901211 1901761 1960191 */

do i=1 to 6;
if stat_n(i)=-16 then do;
stat_n(i)=-3 ;
end;
end;

/* 3-1-04 set up adopted new child flag. These adopted new children should not be included
in created variables*/
array biores[6] biores1-biores6;
array adoptin (6) adopt1-adopt6;

flagadoptin=0;

do i=1 to 6;
if adoptin(i)=1 and bioid (i)>700 then do;
flagadoptin=1;
bmonth(i)=-4;
byear(i)=-4;
mob(i)=-4;
dmonth(i)=-4;
dyear(i)=-4;
mod(i)=-4;
status(i)=-4;
stat_n(i)=-4;
end;
end;

/* END OF ROUND 7 FIXES */

/* sixth, the number of children ever born and residing in the household (tbiores) */

/*array biores[6] biores1-biores6;*/

do i=1 to 6;
biores(i)=0;
if stat_n(i) eq 5 then biores(i)=1;
end;

tbiores=biores1+biores2+biores3+biores4+biores5+biores6;
if stat_n1=-3 or stat_n2=-3 or stat_n3=-3 or stat_n4=-3 or stat_n5=-3 or stat_n6=-3
then tbiores=-3;
if (mob1=-4 and mob2=-4 and mob3=-4 and mob4=-4 and mob5=-4 and mob6=-4) then tbiores=-4;
if mob1=-5 then tbiores=-5;

/* seventh, the number of children ever born and not residing in the household (tbionres) */

array bionres[6] bionres1-bionres6;

do i=1 to 6;
bionres(i)=0;
if (stat_n(i) eq 1 or stat_n(i) eq 3 or stat_n(i) eq 4) and stat_n(i) ne 2 then bionres(i)=1;
end;

tbionres=bionres1+bionres2+bionres3+bionres4+bionres5+bionres6;
if stat_n1=-3 or stat_n2=-3 or stat_n3=-3 or stat_n4=-3 or stat_n5=-3 or stat_n5=-3
then tbionres=-3;
if (mob1=-4 and mob2=-4 and mob3=-4 and mob4=-4 and mob5=-4 and mob5=-4) then tbionres=-4;
if mob1=-5 then tbionres=-5;

/* Last, sort created variables by birthdays, so that the first child listed is the oldest child. */
array smob[6] smob1-smob6;

do i=1 to 6;
smob(i)=mob(i);
end;

do i=1 to 6;
if mob(i)=-3 then smob(i)=1000;
if mob(i)=-4 then smob(i)=9999;
end;

m1=-4;
m2=-4;
m3=-4;
m4=-4;
m5=-4;
m6=-4;

/* order the children by birthdate, start with oldest */
m1=min(smob1, smob2, smob3, smob4, smob5, smob6);
/* set min birthdate to missing to remove from potential list */
if m1=smob1 then smob1=9999;
else if m1=smob2 then smob2=9999;
else if m1=smob3 then smob3=9999;
else if m1=smob4 then smob4=9999;
else if m1=smob5 then smob5=9999;
else if m1=smob6 then smob6=9999;

/* move onto second oldest */
m2=min(smob1, smob2, smob3, smob4, smob5, smob6);
if m2=smob1 then smob1=9999;
else if m2=smob2 then smob2=9999;
else if m2=smob3 then smob3=9999;
else if m2=smob4 then smob4=9999;
else if m2=smob5 then smob5=9999;
else if m2=smob6 then smob6=9999;

/* move onto third oldest */
m3=min(smob1, smob2, smob3, smob4, smob5, smob6);
if m3=smob1 then smob1=9999;
else if m3=smob2 then smob2=9999;
else if m3=smob3 then smob3=9999;
else if m3=smob4 then smob4=9999;
else if m3=smob5 then smob5=9999;
else if m3=smob6 then smob6=9999;

/* move onto fourth oldest */
m4=min(smob1, smob2, smob3, smob4, smob5,smob6);
if m4=smob1 then smob1=9999;
else if m4=smob2 then smob2=9999;
else if m4=smob3 then smob3=9999;
else if m4=smob4 then smob4=9999;
else if m4=smob5 then smob5=9999;
else if m4=smob6 then smob6=9999;

/* move onto fifth oldest */
m5=min(smob1, smob2, smob3, smob4, smob5, smob6 );
if m5=smob1 then smob1=9999;
else if m5=smob2 then smob2=9999;
else if m5=smob3 then smob3=9999;
else if m5=smob4 then smob4=9999;
else if m5=smob5 then smob5=9999;
else if m5=smob6 then smob6=9999;

/* move onto sixth oldest */
m6=min(smob1, smob2, smob3, smob4, smob5, smob6);
if m6=smob1 then smob1=9999;
else if m5=smob2 then smob2=9999;
else if m5=smob3 then smob3=9999;
else if m5=smob4 then smob4=9999;
else if m5=smob5 then smob5=9999;
else if m5=smob6 then smob6=9999;

if m1=9999 then m1=-4;
if m2=9999 then m2=-4;
if m3=9999 then m3=-4;
if m4=9999 then m4=-4;
if m5=9999 then m5=-4;
if m6=9999 then m6=-4;

if m1=1000 then m1=-3;
if m2=1000 then m2=-3;
if m3=1000 then m3=-3;
if m4=1000 then m4=-3;
if m5=1000 then m5=-3;
if m6=1000 then m6=-3;

array cv03bm[6] cv03bm1-cv03bm6;
array cv03by[6] cv03by1-cv03by6;
array cv03mob[6] cv03mob1-cv03mob6;
array cv03dm[6] cv03dm1-cv03dm6;
array cv03dy[6] cv03dy1-cv03dy6;
array cv03mod[6] cv03mod1-cv03mod6;
array cv03stat[6] cv03sta1-cv03sta6;

do i=1 to 6;
if m1=mob(i) then do;
cv03bm1 =bmonth(i);
cv03by1 =byear(i);
cv03mob1=mob(i);
cv03dm1 =dmonth(i);
cv03dy1 =dyear(i);
cv03mod1=mod(i);
cv03sta1=stat_n(i);
end;
end;

do i=1 to 6;
if m2=mob(i) then do;
cv03bm2 =bmonth(i);
cv03by2 =byear(i);
cv03mob2=mob(i);
cv03dm2 =dmonth(i);
cv03dy2 =dyear(i);
cv03mod2=mod(i);
cv03sta2=stat_n(i);
end;
end;

do i=1 to 6;
if m3=mob(i) then do;
cv03bm3 =bmonth(i);
cv03by3 =byear(i);
cv03mob3=mob(i);
cv03dm3 =dmonth(i);
cv03dy3 =dyear(i);
cv03mod3=mod(i);
cv03sta3=stat_n(i);
end;
end;

do i=1 to 6;
if m4=mob(i) then do;
cv03bm4 =bmonth(i);
cv03by4 =byear(i);
cv03mob4=mob(i);
cv03dm4 =dmonth(i);
cv03dy4 =dyear(i);
cv03mod4=mod(i);
cv03sta4=stat_n(i);
end;
end;

do i=1 to 6;
if m5=mob(i) then do;
cv03bm5 =bmonth(i);
cv03by5 =byear(i);
cv03mob5=mob(i);
cv03dm5 =dmonth(i);
cv03dy5 =dyear(i);
cv03mod5=mod(i);
cv03sta5=stat_n(i);
end;
end;

do i=1 to 6;
if m6=mob(i) then do;
cv03bm6 =bmonth(i);
cv03by6 =byear(i);
cv03mob6=mob(i);
cv03dm6 =dmonth(i);
cv03dy6 =dyear(i);
cv03mod6=mod(i);
cv03sta6=stat_n(i);
end;
end;

/*3-2-05 Child deleted by Respondent from Roster in survery and also deleted in BIOCHO ROSTER
R's went though question YFER1810=1 and YFER1820=1*/
array dchild (6) dchild01-dchild06;
array ddchild (6) ddchild01-ddchild06;
array cvmob (6) cv01-cv06;

do i=1 to 6;
if dchild(i)=1 and ddchild(i)=1 then flagdelete=1;
if (flagdelete=1 and mob(i)=-4 and cvmob(i)>0)
or (flagdelete=1 and cv01=-5 and cv03mob1=-4)
or PUBID=440 then flagdeletea=1;
end;

if flagdeletea=1 and cv03mob1=-4 and cv01>0 then do;
cv03bm1= cvR6bm1;
cv03by1= cvR6by1;
cv03mob1=cv01;
cv03sta1 =6;
tbiores =-3;
tbionres=-3 ;
end;

if PUBID=440 then do;
cv03bm4= cvR6bm2;
cv03by4= cvR6by2;
cv03mob4=cv02;
cv03sta4 =6;

tbiores =-3;
tbionres=-3 ;
end;

if PUBID=3977 then do;
cv03bm1= cvR2bm1;
cv03by1= cvR2by1;
cv03mob1=cvR2mob1;
cv03sta1 =6;
tbiores =-3;
tbionres=-3 ;
end;

/* Cases deleted in R6 by Respondent from Roster in survery
F1810=1 and F1820=1 But they are in R5 */
if PUBID in (1792,2019,8057) then do;
cv03bm1= cvR5bm1;
cv03by1= cvR5by1;
cv03mob1=cvR5mob1;
cv03sta1 =6;
tbiores =-3;
tbionres=-3 ;
end;

/* F1810=1 and F1820=1 Cases deleted in R5 by Respondent from Roster in survey But they are in R4 */
if PUBID in (4320, 7676) then do;
cv03bm1= cvR4bm1;
cv03by1= cvR4by1;
cv03mob1=cvR4mob1;
cv03sta1 =6;
tbiores =-3;
tbionres=-3 ;
end;

/*F1810=1 and F1820=1 Cases deleted in R5 by Respondent in survey But they are in R3 */
if PUBID= 8347 then do;
cv03bm2= cvR3bm1;
cv03by2= cvR3by1;
cv03mob2=cvR3mob1;
cv03sta2 =6;
tbiores =-3;
tbionres=-3 ;
end;

do i=1 to 6;
if dmonth(i)=-5 then do;
cv03dm[i]=-5;
cv03dy[i]=-5;
cv03mod[i]=-5;
end;
end;

/* 2-28-05 Hand edit cases who have incorrect birthday in R6. correct birthday in R5
They went through YFER1200 YFER1300 in R5 and corrected wrong birthday*/

if PUBID =1722 then do;
cv03bm1=4;
cv03by1=1999;
cv03mob1=232;
end;

if PUBID=6169 then do;
cv03bm2=1;
cv03mob2=265;
end;

if PUBID=9004 then do;
cv03by2=2001;
cv03mob2=253;
end;


endsas;

Return to top


Number of Residences Since Age 12

Variables Created: CV_TTL_RESIDENCES 2003

Variables Used

Name in Program

Question Name on CD

resid_r1 CV_TTL_RESIDENCES 1997
resid_r2 CV_TTL_RESIDENCES 1998
resid_r3 CV_TTL_RESIDENCES 1999
resid_r4 CV_TTL_RESIDENCES 2000
resid_r5 CV_TTL_RESIDENCES 2001
resid_r6 CV_TTL_RESIDENCES 2002
y3500 YHHI-3500
y3600 YHHI-3600
c1070 YCHR-1070
c1070a YCHR-1070a
c1080 YCHR-1080
c1090 YCHR-1090
pubid PUBID
intd SYMBOL!CURDATE~D
intm SYMBOL!CURDATE~M
inty SYMBOL!CURDATE~Y

This program calculates the number of residences in which youth has lived since age 12. In round 1, the variable was created with information from the parent interview.  In round 2, information collected from the respondent was combined with the round 1 variable to update the previous information. Subsequent rounds continue to update the variable with respondent-provided data.


** Initialize RESID;
RESID=-4;

** If R interviewed in Round 7;
array resid_r (*) resid_r1-resid_r6;

do i=1 to dim(resid_r);
if resid_r(i)~=-5 then do;
residP=resid_r(i);
dli_rnd=i;
end;
end;

** Wrong input information.;
if PUBID=406 then do;
intd=2;
intm=1;
inty=2004;
y3500=1;
y3600=1;
handedit=1;
end;

if residP=-1|y3600=-1 then RESID=-3; * refusal in DLI or in Round 7;
if residP=-2|y3600=-2 then RESID=-3; * dont know in DLI or in Round 7;
if residP=-3 then RESID=-3; * parents not intd in Round 1;
if dli_rnd=1 & residP=-4 then RESID=-3; * parents not intd in Round 1, R last intd in Round 1;

if residP>=0 & y3600>=0 then RESID=residP+y3600; * parents intd in Round 1 & all responses valid;
if residP>=0 & y3500=0 then RESID=residP;

** If R not interviewed in Round 7;
if y3500=-5 then RESID=-5;
label RESID = "CV_TTL_RESIDENCES 2003";

drop i;

** Check if Rs interviewed in Round 7 but whose parents were not interviewed in Round 1 get RESID=-3. If
they do not then prob1=1;
prob1=0;
if resid_r1=-4 & y3500~=-5 & RESID~=-3 then prob1=1;

** Check if RESID ever flips across the rounds. If so then prob2=1;
prob2=0;
do i=2 to dim(resid_r);
if resid_r(i-1)>resid_r(i)>=0 then prob2=prob2+1;
end;
if resid_r6>RESID>=0 then prob2=prob2+1;

ENDSAS;

Return to top


Citizenship Status

Variables Created: CV_CITIZEN_CURRENT

Variables Used

Name in Program

Question Name on CD

usborn YHHI-55701
sborn YHHI-55702
cborn YHHI-55703
citist YHHI-55704
cciti YHHI-55705A
nocitist1-7 YHHI-55706~000001-~000007
pubid PUIBID

Codes for Created Variables

1. Citizen, born in the US
2. Citizen, naturalized
3. Applicant for naturalization
4. Permanent resident
5. Applicant for residence
6. Other

This program creates a variable describing the youth's citizenship status.


if citizen01>-4 then citizen=citizen01;
if citizen02>-4 then citizen=citizen02;

if usborn=1 or citist=1 then citizen=1;
else if citist=2 then citizen=2;
else if citist=3 and cciti=1 then do;
if nocitist1 =1 then citizen=3;
else if nocitist2=1 then citizen=4;
else if nocitist3=1 then citizen=5;
else if nocitist4=1 or nocitist5=1 or nocitist6=1 or nocitist7=1 then citizen=6;
end;
if -4<citist<0 then citizen=-3;
if int_y=-5 then citizen=-5;

endsas;


Return to top Return to Table of Contents