/******************** Variables Used ********************/ /**Variable Names in Program Variable Names in Gator**/ PUBID PUBID dob01d, m, y KEY!BDATE_D, _M, _Y P3051Y1-P3051Y6 P3-051.01_Y-.06_Y P305301-P305306 P3-053.01-.06 P3067Y1-P3067Y6 P3-067.01_Y-.06_Y P3067Y2-5 P3-067.02_Y-.05_Y P818100-13 PC8-018.01_001-_014 P8181000-13 PC8-018.10_001-_014 P8181100-13 PC8-018.11_001-_014 P8181200-13 PC8-018.12_001-_014 P8181300-13 PC8-018.13_001-_014 P8181400-13 PC8-018.14_001-_014 P8181500-13 PC8-018.15_001-_014 P8181600-13 PC8-018.16_001-_014 P8181700-13 PC8-018.17_001-_014 P818200-13 PC8-018.02_001-_014 P818300-13 PC8-018.03_001-_014 P818400-13 PC8-018.04_001-_014 P818500-13 PC8-018.05_001-_014 P818600-13 PC8-018.06_001-_014 P818700-13 PC8-018.07_001-_014 P818800-13 PC8-018.08_001-_014 P818900-13 PC8-018.09_001-_014 PC801901-17 PC8-019.01-.17 PC802001-16 PC8-020.01-.16 PC802101-16 PC8-021.01-.16 PC802201-16 PC8-022.01-.16 PC803101-11 PC8-031.01-.11 PC803201-11 PC8-032.01-.11 PC803501-10 PC8-035.01-.10 /******************** SAS code for variable creation ********************/ array yrelate(3) yrelate2 yrelate6 yrelat12; array continue(6) p305301-p305306; array maryear(6) p3051y1-p3051y6; array stopyear(6) p3067y1-p3067y6; array stoplive(16) pc802201-pc802216; array livewh(17, 14) p818100-p818113 p818200-p818213 p818300-p818313 p818400-p818413 p818500-p818513 p818600-p818613 p818700-p818713 p818800-p818813 p818900-p818913 p8181000-p8181013 p8181100-p8181113 p8181200-p8181213 p8181300-p8181313 p8181400-p8181413 p8181500-p8181513 p8181600-p8181613 p8181700-p8181713; array awayyear(10) pc803501-pc803510; array awaywho(11) pc803201-pc803211; array loopnum(3) loopnum2 loopnum6 loopnm12; array respondt(17) pc801901-pc801917; array noknow(17) pc802001-pc802017; array refuse(17) pc802101-pc802117; array place(11) pc803101-pc803111; array lastnum(3) lastnum1 lastnum2 lastnum3; array flag1(3) flag11 flag22 flag33; /****program starts here***/ /***three loops because of 2, 6, 12***/ do i= 1 to 3; if i=1 then age=dob01y+2; else if i=2 then age=dob01y+6; else if i=3 then age=dob01y+12; /*** Initialize everyone to zero or -4 ***/ yrelate(i)=0; loopnum(i)=0; /***********************************************************************************************************************\ | 1. The youth lived prior to live with parents | \***********************************************************************************************************************/ if age > 1900 then do; /***cases satisfied the following condition should have yrelate > 0. For age 2. the exception is those exiting from the first loop and stay with respondent or don't know or refuse this information; don't know or refuse in year first lived together; and don't know or refused the year relationship ended. If the year of the last loop larger than 0 but less than age then exit condition with the respondent then compute in the following sections. These cases still have yrelate=0 after this section and will be processed in section 2 or section 3. The same process is followed for age 6 and 12.***/ if pc8009y1 >=age or pc8009y1 in (-1,-2) then do; /****a. identify the loop number into which age 2 (6,12) falls****/ /***note that if there are multiple changes in the age year then the loopnum takes the last one***/ /***there are 15 loops because of the 'j+1,' and the 17th loop is the respondent***/ do j=1 to 15; if stoplive(1) >=age then loopnum(i)=1; if 0 < stoplive(j) < age and stoplive(j+1) >= age then loopnum(i)=j+1; /***the next line ensures that the last relationship reported during the age is the one we use***/ if stoplive(j)=stoplive(j+1)=age then loopnum(i)=j+1; end; /***above deals with the 'good' data; below deals with the 'obnoxious' data**/ /***max year of the prior loops**/ maxyear=max(of pc802201-pc802216); /*** taking care of the cases for pc8009y1 (year first lived)>=age and loopnum(i)=0 (exit from the first loop, age does not fall into any interval due to -1, -2 in stoplive or errors in reported date)***/ if loopnum(i)=0 and pc8009y1 >=age then do; /***note that if the loop ended in the first loop, then maxyear=-4, loopnum(i)=0;***/ /***the situation that maxyear=-4 and respondt(1)=1 (exit condition for 1st loop) will be taken care of later; takes care of the dk, refuse first***/ if maxyear=-4 and noknow(1)=1 then loopnum(i)=-2; if maxyear=-4 and refuse(1)=1 then loopnum(i)=-1; /***reported error - dont know or refuse the year or give 'wrong' year (inconsistancy)***/ if maxyear in (-1,-2) then loopnum(i)=maxyear; else if 0 < maxyear < age then loopnum(i)=-1 ; else if maxyear >=age then do k=1 to 16; if stoplive(k)in (-1,-2) and loopnum(i) ^=-1 then loopnum(i)=stoplive(k); end; end; /*** taking care of the cases when pc8009y1 is -1 (-2) and loopnum=0***/ if loopnum(i)=0 and pc8009y1 in (-1,-2) then do; if maxyear in (-1,-2,-4) and (pc802601 >=age or pc802601 in (-1,-2,-4)) then loopnum(i)=pc8009y1; /***for those with pc802601< age, loopnum=0(yrelate=0)***/ if maxyear >=age then loopnum(i)=pc8009y1; counter1=0; /***this determines the last loop reported by a respondent, regardless of whether the data are real, dont know or refuse***/ if 0 < maxyear < age then do; do j=1 to 16; /***find out which loop is the last one ***/ if stoplive(j)=-4 and counter1=0 then do; lastloop=j-1; counter1=counter1+1; end; end; if j=16 and stoplive(16) ^=-4 then lastloop=16; *********if stoplive(lastloop)>0 (valid year) and respondt(lastloop+1)=1 computed in one of the following sections - 2 or 3; if stoplive(lastloop)>0 and (noknow(lastloop+1)=1 or refuse(lastloop+1)=1) then loopnum(i)=pc8009y1; if stoplive(lastloop) in (-1,-2) then loopnum(i)=pc8009y1; end; end; /***b. recode the yrelate***/ if loopnum(i) in (-1,-2) then yrelate(i)=loopnum(i); if loopnum(i) > 0 then do; /** lived withh bio. mom, marital status unknown ***/ if livewh(loopnum(i),2 )=1 then yrelate(i)=4; /*** lived with bio dad, marital status unknown***/ if livewh(loopnum(i),3 )=1 then yrelate(i)=5; /*** lived with both biological parents***/ if livewh(loopnum(i),2 )=1 and livewh(loopnum(i),3)=1 then yrelate(i)=1; /*** lived with adoptive parents***/ /*** lived with other adults, bio. parent status unknown, not group qtrs ***/ if livewh(loopnum(i),4 )=1 then yrelate(i)=8; if livewh(loopnum(i),5 )=1 then yrelate(i)=8; /*** lived with foster parents***/ if livewh(loopnum(i),7 )=1 then yrelate(i)=7; /***lived in group quarters***/ do k = 8,9,10,11,12; if livewh(loopnum(i),k )=1 then yrelate(i)=9; end; /*** any other living arrangement***/ do k = 6,13,14; if livewh(loopnum(i),k )=1 then yrelate(i)=10; end; end; end; /***********************************************************************************************************************\ | 2. check for periods spent away from parents, pc802601 -4 then lastchg=10; /***find out into which loop the age falls ***/ do j=1 to lastchg; /***10 equals to the maximum complete spells away from parents***/ if j=1 and awayyear(1)=-4 then lastnum(i)=1; /*****?????need to check***/ if j=1 and awayyear(1) >= age then lastnum(i)=1; if j < lastchg and 0< awayyear(j) < age and awayyear(j+1) >= age then lastnum(i)=j+1; if j < lastchg and awayyear(j)=awayyear(j+1)=age then lastnum(i)=j+1; if j=lastchg and 0 < awayyear(lastchg)< age then lastnum(i)=lastchg+1; end; if lastnum(i)=. then lastnum(i)=-1; /***if there is -1/-2 in awayear, no such cases in current data***/ /***r goes on to give more data, but the year info in the first loop is invalid***/ if lastnum(i)=1 and nochange ^= 1 and pc802601 in (-1,-2) then yrelate(i)=pc802601; /***yrelate=-1 or -2***/ if lastnum(i)=-1 then yrelate(i)=-1; if yrelate(i) =0 then do; if place(lastnum(i)) in (-1,-2) then yrelate(i)=place(lastnum(i)); if place(lastnum(i)) in (1,4) then yrelate(i)=10; /***coded as 'anything else'***/ if place(lastnum(i))=3 then yrelate(i)=9; /***group quarters***/ if place(lastnum(i))=2 then do; /****if repondent (1) is coded [awaywho(lastnum(i))=1] then go to section 3 to determine marital status***/ if awaywho(lastnum(i)) = 2 then yrelate(i)=1; if awaywho(lastnum(i)) = 3 then yrelate(i)=4; if awaywho(lastnum(i)) = 4 then yrelate(i)=5; if awaywho(lastnum(i)) in (5,6,11) then yrelate(i)=8; if awaywho(lastnum(i)) in (7,8,9) then yrelate(i)=10; if awaywho(lastnum(i)) =10 then yrelate(i)=7; if awaywho(lastnum(i))in (-1,-2) then yrelate(i)=awaywho(lastnum(i)); /*****check***/ end; end; end; /***********************************************************************************************************************\ | 3. The youth lived with parents continuously or the first separation is >= age. | or the seperation time is with respondent. | flag2 = 1 indicates that a marriage happend before or when youth is 2 (6,12) and ended when or after youth is 2 | \***********************************************************************************************************************/ if yrelate(i)=0 and pc802501 in (-1,-2) then yrelate(i)=pc802501; if yrelate(i)=0 and ( (pc802501=0) or (pc802501=1 and pc802601 >= age) or ( (pc802501=1) and (pc802601 < age )) ) then do; do j = 1 to 6;/*** Determine if the youth has lived with both parnts since living with the respondent ***/ if continue(j)=1 and ( 0 =< dob01y - maryear(j) < 1900 ) and ythpar01 in (3,4) and yth2bios=1 then do; yrelate(i)=1; end; end; if yrelate(i)=0 then do; if max(of p3051y1-p3051y6)=-4 then flag1(i)=-4; do j=1 to 6; if j = < 5 and (1900 < maryear(j) < age ) and (stopyear(j) >=age) then flag1(i)=1; else if j=6 and (1900 < maryear(j) < age) then flag1(i)=1; end; if flag1(i)=. then flag1(i)=-1; /***for those with -1,-2 in the age period or the age is not with any marriages ***/ if flag1(i)=1 then do; if ythpar01=3 then yrelate(i)=2; /*** bio. mom, other parent figure present ***/ else if ythpar01=4 then yrelate(i)=3; /*** bio. dad, other parent figure present ***/ end; else if flag1(i) in (-1,-4) then do; if ythpar01=3 then yrelate(i)=4; else if ythpar01=4 then yrelate(i)=5; end; if ythpar01 in (5,6) then yrelate(i)=6; /*** adoptive parents ***/ else if ythpar01 in (9,10) then yrelate(i)=7; /*** foster/temporary parents ***/ else if ythpar01 not in (3,4,5,6,9,10) then yrelate(i)=8; /*** other adults, bio. parent status unknown***/ end; end; end; end; if pc800401=-4 then yrelate2=-4; if pc800401=-4 then yrelate6=-4; if pc800401=-4 then yrelat12=-4; endsas;