Return to Appendix 2 main file
/*preliminary steps*/
r1int_d=R1209400; label r1int_d = "CV_INTERVIEW_DATE 1997";
r1int_m=R1209401; label r1int_m = "CV_INTERVIEW_DATE 1997";
r1int_y=R1209402; label r1int_y = "CV_INTERVIEW_DATE 1997";
r2int_d=R2568300; label r2int_d = "CV_INTERVIEW_DATE 1998";
r2int_m=R2568301; label r2int_m = "CV_INTERVIEW_DATE 1998";
r2int_y=R2568302; label r2int_y = "CV_INTERVIEW_DATE 1998";
r3int_d=R3890300; label r3int_d = "CV_INTERVIEW_DATE 1999";
r3int_m=R3890301; label r3int_m = "CV_INTERVIEW_DATE 1999";
r3int_y=R3890302; label r3int_y = "CV_INTERVIEW_DATE 1999";
r4int_d=R5472300; label r4int_d = "CV_INTERVIEW_DATE 2000";
r4int_m=R5472301; label r4int_m = "CV_INTERVIEW_DATE 2000";
r4int_y=R5472302; label r4int_y = "CV_INTERVIEW_DATE 2000";
r5int_d=R7236100; label r5int_d = "CV_INTERVIEW_DATE 2001";
r5int_m=R7236101; label r5int_m = "CV_INTERVIEW_DATE 2001";
r5int_y=R7236102; label r5int_y = "CV_INTERVIEW_DATE 2001";
r6int_d=S1550900; label r6int_d = "CV_INTERVIEW_DATE 2002";
r6int_m=S1550901; label r6int_m = "CV_INTERVIEW_DATE 2002";
r6int_y=S1550902; label r6int_y = "CV_INTERVIEW_DATE 2002";
r7int_d=S2020800; label r7int_d = "CV_INTERVIEW_DATE 2003";
r7int_m=S2020801; label r7int_m = "CV_INTERVIEW_DATE 2003";
r7int_y=S2020802; label r7int_y = "CV_INTERVIEW_DATE 2003";
r8int_d=S3822000; label r8int_d = "CV_INTERVIEW_DATE 2004";
r8int_m=S3822001; label r8int_m = "CV_INTERVIEW_DATE 2004";
r8int_y=S3822002; label r8int_y = "CV_INTERVIEW_DATE 2004";
r9int_d=S5422000; label r9int_d = "CV_INTERVIEW_DATE 2005";
r9int_m=S5422001; label r9int_m = "CV_INTERVIEW_DATE 2005";
r9int_y=S5422002; label r9int_y = "CV_INTERVIEW_DATE 2005";
run;
data emp_bday (keep=idcode birthwk age14wk age18wk age20wk);
set two (keep=idcode R9169200 -- R9169500); by idcode;
birthwk=R9169500; /*internal variable*/
age14wk=R9169200; /*internal variable*/
age18wk=R9169300; /*internal variable*/
age20wk=R9169400; /*internal variable*/
proc means n mean min max data=emp_bday;
var idcode birthwk age14wk age18wk age20wk;
title 'Round9';
title2 'Emp_bday';
run;
data emp_int(keep=idcode r1int r2int r3int r4int r5int r6int r7int r8int r9int);
set two(keep=idcode R9169600 -- R9170100 R9270400 R9270500
r9int_m r9int_d r9int_y); by idcode;
if r9int_y>0 then r9mdy=mdy(r9int_m,r9int_d,r9int_y);
begmdy=mdy(01,01,1980);
r1int=R9169600;
r2int=R9169700;
r3int=R9169800;
r4int=R9169900;
r5int=R9170000;
r6int=R9170100;
r7int=R9270400;
r8int=R9270500;
r9int=intck('week',begmdy,r9mdy)+1; if r9int=. then r9int=-5;
proc means n mean min max data=emp_int;
title2 'Emp_int';
run;
data emp_week; merge two emp_bday emp_int; by idcode;
if R9int>-5;
if S6862302=1900 then S6862302=-3; *impossible stop year for 2005 job;
/* Establish dli week*/
if r8int_y>0 then do;
dli_y=r8int_y;
dli_m=r8int_m;
dli_d=r8int_d;
dliwk=r8int;
end;
if r8int_y=-5 and r7int_y>0 then do;
dli_y=r7int_y;
dli_m=r7int_m;
dli_d=r7int_d;
dliwk=r7int;
end;
if r8int_y=-5 and r7int_y=-5 and r6int_y>0 then do;
dli_y=r6int_y;
dli_m=r6int_m;
dli_d=r6int_d;
dliwk=r6int;
end;
if r8int_y=-5 and r7int_y=-5 and r6int_y=-5 and r5int_y>0 then do;
dli_y=r5int_y;
dli_m=r5int_m;
dli_d=r5int_d;
dliwk=r5int;
end;
if r8int_y=-5 and r7int_y=-5 and r6int_y=-5 and r5int_y=-5 and r4int_y>0 then
do;
dli_y=r4int_y;
dli_m=r4int_m;
dli_d=r4int_d;
dliwk=r4int;
end;
if r8int_y=-5 and r7int_y=-5 and r6int_y=-5 and r5int_y=-5 and r4int_y=-5 and
r3int_y>0 then do;
dli_y=r3int_y;
dli_m=r3int_m;
dli_d=r3int_d;
dliwk=r3int;
end;
if r8int_y=-5 and r7int_y=-5 and r6int_y=-5 and r5int_y=-5 and r4int_y=-5 and
r3int_y=-5 and r2int_y>0 then do;
dli_y=r2int_y;
dli_m=r2int_m;
dli_d=r2int_d;
dliwk=r2int;
end;
if r8int_y=-5 and r7int_y=-5 and r6int_y=-5 and r5int_y=-5 and r4int_y=-5 and
r3int_y=-5 and r2int_y=-5 and r1int_y>0 then do;
dli_y=r1int_y;
dli_m=r1int_m;
dli_d=r1int_d;
dliwk=r1int;
end;
/* ostartm represents the "old" start dates, and startm the start dates with
imputed values */
array ostartm (j) &R9STAM;
array ostartd (j) &R9STAD;
array ostarty (j) &R9STAY;
array ostopm (j) &R9STOM;
array ostopd (j) &R9STOD;
array ostopy (j) &R9STOY;
array UID (j) &R9UID;
array self (j) &R9SEL;
array milflag (j) &R9MIL;
array startm (j) starm01-starm09;
array startd (j) stard01-stard09;
array starty (j) stary01-stary09;
array stopm (j) stopm01-stopm09;
array stopd (j) stopd01-stopd09;
array stopy (j) stopy01-stopy09;
array smofl (j) smof01-smof09; /* dummy equals 1 when a start month is imputed
*/
array emofl (j) emof01-emof09; /* dummy equals 1 when a stop month is imputed */
array _strmdy (j) _strmdy01-_strmdy09;
array _stpmdy (j) _stpmdy01-_stpmdy09;
array _startwk (j) starw01-starw09;
array _stopwk (j) stopw01-stopw09;
begmdy=mdy(01,01,1980);
_1994mdy=mdy(01,01,1994);
_1995mdy=mdy(01,01,1995);
_1996mdy=mdy(01,01,1996);
_1997mdy=mdy(01,01,1997);
_1998mdy=mdy(01,01,1998);
_1999mdy=mdy(01,01,1999);
_2000mdy=mdy(01,01,2000);
_2001mdy=mdy(01,01,2001);
_2002mdy=mdy(01,01,2002);
_2003mdy=mdy(01,01,2003);
_2004mdy=mdy(01,01,2004);
_2005mdy=mdy(01,01,2005);
_2006mdy=mdy(01,01,2006);
_2007mdy=mdy(01,01,2007);
wk1_1994=intck('week',begmdy,_1994mdy)+1; label wk1_1994='Continuous week
1/1/94';
wk1_1995=intck('week',begmdy,_1995mdy)+1; label wk1_1995='Continuous week
1/1/95';
wk1_1996=intck('week',begmdy,_1996mdy)+1; label wk1_1996='Continuous week
1/1/96';
wk1_1997=intck('week',begmdy,_1997mdy)+1; label wk1_1997='Continuous week
1/1/97';
wk1_1998=intck('week',begmdy,_1998mdy)+1; label wk1_1998='Continuous week
1/1/98';
wk1_1999=intck('week',begmdy,_1999mdy)+1; label wk1_1999='Continuous week
1/1/99';
wk1_2000=intck('week',begmdy,_2000mdy)+1; label wk1_2000='Continuous week
1/1/00';
wk1_2001=intck('week',begmdy,_2001mdy)+1; label wk1_2001='Continuous week
1/1/01';
wk1_2002=intck('week',begmdy,_2002mdy)+1; label wk1_2002='Continuous week
1/1/02';
wk1_2003=intck('week',begmdy,_2003mdy)+1; label wk1_2003='Continuous week
1/1/03';
wk1_2004=intck('week',begmdy,_2004mdy)+1; label wk1_2004='Continuous week
1/1/04';
wk1_2005=intck('week',begmdy,_2005mdy)+1; label wk1_2005='Continuous week
1/1/05';
wk1_2006=intck('week',begmdy,_2006mdy)+1; label wk1_2006='Continuous week
1/1/06';
wk1_2007=intck('week',begmdy,_2007mdy)+1; label wk1_2007='Continuous week
1/1/07';
do j=1 to 9;
if uid ge 9701 then do;
if ostartm>0 and ostartd>0 and ostarty>1979 then
_strmdy=mdy(ostartm,ostartd,ostarty);
if ostartm>0 and ostartd in (-1,-2,-3) and ostarty>1979 then
_strmdy=mdy(ostartm,1,ostarty);
if ostartm in (-1,-2,-3) and ostartd>0 and ostarty>1979 then
_strmdy=mdy(1,ostartd,ostarty);
if ostartm in (-1,-2,-3) and ostartd in (-1,-2,-3) and ostarty>1979 then
_strmdy=mdy(1,1,ostarty);
if ostopm>0 and ostopd>0 and ostopy>1979 then _stpmdy=mdy(ostopm,ostopd,ostopy);
if ostopm>0 and ostopd in (-1,-2,-3) and ostopy>1979 then
_stpmdy=mdy(ostopm,28,ostopy);
if ostopm in (-1,-2,-3) and ostopd>0 and ostopy>1979 then
_stpmdy=mdy(12,ostopd,ostopy);
if ostopm in (-1,-2,-3) and ostopd in (-1,-2,-3) and ostopy>1979 then
_stpmdy=mdy(12,28,ostopy);
if _strmdy>0 then _startwk=intck('week',begmdy,_strmdy)+1;
if _stpmdy>0 then _stopwk =intck('week',begmdy,_stpmdy)+1;
if 9701 le uid<200500 and _startwk>0 and dliwk>_startwk then _startwk=dliwk;
if 9701 le uid<200500 and _stopwk>0 and dliwk>_stopwk then _stopwk=dliwk;
/*for jobs with start/stop on/after int set start/stop to week before int*/
if _stopwk ge r9int then _stopwk=r9int-1;
if _startwk ge r9int then _startwk=r9int-1;
if ostarty in (-1,-2,-3,-4) then _startwk=-3;
if ostopy in (-1,-2,-3,-4) then _stopwk=-3;
if _startwk>0 and _stopwk>0 and _startwk>_stopwk then _startwk=_stopwk;
end;
end;
/* Define new start and stop dates */
do j=1 to 9; if uid ge 9701 then do;
startm=ostartm;
startd=ostartd;
starty=ostarty;
stopm=ostopm;
stopd=ostopd;
stopy=ostopy;
end; end;
***Fill-in start/stop day for those missing;
/* flag1 = impute start day (valid month)
flag2 = impute start month (valid day)
flag3 = impute start day and month
flag4 = impute stop day (valid month)
flag5 = impute stop month (valid day)
flag6 = impute stop day and month */
array flag1 (j) flag101-flag109;
array flag2 (j) flag201-flag209;
array flag3 (j) flag301-flag309;
array flag4 (j) flag401-flag409;
array flag5 (j) flag501-flag509;
array flag6 (j) flag601-flag609;
/* Impute missing start days to 1, missing stop days to 28, missing start month
to 1 (Jan.) and missing stop months to 12 (Dec.). */
/* Reset flag(1-3) to zero when the start year is valid */
do over starty;
if starty>0 then do;
if startm>0 and startd<=0 then do;
startd=1;
flag1=1;
end;
if startm<=0 and startd>0 then do;
startm=1;
flag2=1;
smofl=1;
end;
if startm<=0 and startd<=0 then do;
startm=1;
startd=1;
flag3=1;
smofl=1;
end;
end;
end;
do over stopy;
if stopy>0 then do;
if stopm>0 and stopd<=0 then do;
stopd=28;
flag4=1;
end;
if stopm<=0 and stopd>0 then do;
stopm=12;
flag5=1;
emofl=1;
end;
if stopm<=0 and stopd<=0 then do;
stopm=12;
stopd=28;
flag6=1;
emofl=1;
end;
/* The following lines prevent values for stop months and days to exceed the
interview date. */
if stopy=r9int_y and stopm=r9int_m and stopd>r9int_d then do;
stopd=r9int_d;
end;
if stopy=r9int_y and stopm>r9int_m then do;
stopm=r9int_m;
stopd=r9int_d;
end;
end;
end;
/* All jobs reported in earlier rounds have their startdates updated to the dli
interview date.*/
do j=1 to 9;
if 9700<uid<200500 and startd>-4 then do;
if starty=dli_y and startm=dli_m and startd<dli_d and starty>0 then do;
startd=dli_d;
end;
if starty=dli_y and startm<dli_m and starty>0 then do;
startm=dli_m;
startd=dli_d;
end;
if starty<dli_y and starty>0 then do;
starty=dli_y;
startm=dli_m;
startd=dli_d;
end;
end;
end;
/* The job start date will be cut off at the week of Jan.1 of the respondent's
18th birthday
for self-employed jobs. One idcode falls into this category.*/
if idcode= 1209 then do;
birthyr=1983;
ag18jmdy=mdy(1,1,birthyr+18);
if ag18jmdy>14974 and ag18jmdy<14982 then ag18jan= 1097;
end;
array bself (j) bself01-bself09;
do over _startwk;
if milflag ne 1 and self=1 and 0<_startwk<=(ag18jan-1) then do;
bself=1; _startwk=ag18jan; starty=birthyr+18; startm=1; startd=1;
end;
end;
/* Check for back-reporters, i.e. a new job that begins before the last
interview date. */
do over UID;
if milflag ne 1 and uid>200500 then do;
if _startwk<r8int and _startwk>0 and r8int=dliwk then do;
back8=1;
end;
if _startwk<r7int and _startwk>0 and r7int=dliwk then do;
back7=1;
end;
if _startwk<r6int and _startwk>0 and r6int=dliwk then do;
back6=1;
end;
if _startwk<r5int and _startwk>0 and r5int=dliwk then do;
back5=1;
end;
if _startwk<r4int and _startwk>0 and r4int=dliwk then do;
back4=1;
end;
if _startwk<r3int and _startwk>0 and r3int=dliwk then do;
back3=1;
end;
if _startwk<r2int and _startwk>0 and r2int=dliwk then do;
back2=1;
end;
if _startwk<r1int and _startwk>0 and r1int=dliwk then do;
back1=1;
end;
end;
end;
array br (j) br01-br09;
back=0;
do over UID;
if milflag ne 1 and uid>200500 and _startwk<dliwk and _startwk>0 and dliwk>0
then do;
back=back+1;
br=1;
end;
end;
run;
data emp_gaps(keep=idcode
BGAP01_01-BGAP01_07 EGAP01_01-EGAP01_07 BGFL01_01 EGFL01_01 EGFL01_02
BGAP02_01-BGAP02_05 EGAP02_01-EGAP02_05 BGFL02_01 EGFL02_01
BGAP03_01-BGAP03_03 EGAP03_01-EGAP03_03 BGFL03_01 EGFL03_01
BGAP04_01-BGAP04_02 EGAP04_01-EGAP04_02
BGAP05_01 EGAP05_01
BGAP06_01-BGAP06_02 EGAP06_01-EGAP06_02); merge two emp_bday emp_int emp_week;
by idcode;
if r9int>-5;
if E1032001=1 then do; E10240002D1=.; E10240002M1=.; E10240002Y1=.;
E10270002D1=.; E10270002M1=.; E10270002Y1=.; end;
*reports 1 gap on job1, dates for gap2 impossible;
/* ENT BEG DATE (SELF-EMP WJGAP),1 ENT BEG DT +1 GAP S-EMP WJGAP,2-3*/
array sbgdy &E10591201D &E10591402D &E10591403D;
array sbgmo &E10591201M &E10591402M &E10591403M;
array sbgyr &E10591201Y &E10591402Y &E10591403Y;
array segdy &E10591601D &E10591602D &E10591603D;
array segmo &E10591601M &E10591602M &E10591603M;
array segyr &E10591601Y &E10591602Y &E10591603Y;
/* ENT BEG M/D/Y WJGAP,1 ENT BEG M/D/Y NEXT WJGAP,2-7*/
array bgdy &E10220001D &E10240002D &E10240003D &E10240004D &E10240005D
&E10240006D
&E10240007D;
array bgmo &E10220001M &E10240002M &E10240003M &E10240004M &E10240005M
&E10240006M
&E10240007M;
array bgyr &E10220001Y &E10240002Y &E10240003Y &E10240004Y &E10240005Y
&E10240006Y
&E10240007Y;
array egdy &E10270001D &E10270002D &E10270003D &E10270004D &E10270005D
&E10270006D
&E10270007D;
array egmo &E10270001M &E10270002M &E10270003M &E10270004M &E10270005M
&E10270006M
&E10270007M;
array egyr &E10270001Y &E10270002Y &E10270003Y &E10270004Y &E10270005Y
&E10270006Y
&E10270007Y;
array bgfl &BGFL_01 &BGFL_02 &BGFL_03 &BGFL_04 &BGFL_05 &BGFL_06 &BGFL_07;
array egfl &EGFL_01 &EGFL_02 &EGFL_03 &EGFL_04 &EGFL_05 &EGFL_06 &EGFL_07;
/*YEMP SELF EMPLOYED (ROS ITEM)*/
array self &R9sel &R9sel &R9sel &R9sel &R9sel &R9sel &R9sel ;
array UID &R9UID &R9UID &R9UID &R9UID &R9UID &R9UID &R9UID;
array milflag &R9MIL &R9MIL &R9MIL &R9MIL &R9MIL &R9MIL &R9MIL;
array stary &R9STAY &R9STAY &R9STAY &R9STAY &R9STAY &R9STAY &R9STAY;
array starm &R9STAM &R9STAM &R9STAM &R9STAM &R9STAM &R9STAM &R9STAM;
array stard &R9STAD &R9STAD &R9STAD &R9STAD &R9STAD &R9STAD &R9STAD;
array stopy &R9STOY &R9STOY &R9STOY &R9STOY &R9STOY &R9STOY &R9STOY;
array stopm &R9STOM &R9STOM &R9STOM &R9STOM &R9STOM &R9STOM &R9STOM;
array stopd &R9STOD &R9STOD &R9STOD &R9STOD &R9STOD &R9STOD &R9STOD;
array starw &STARW &STARW &STARW &STARW &STARW &STARW &STARW;
array stopw &stopW &stopW &stopW &stopW &stopW &stopW &stopW;
array smof &smof &smof &smof &smof &smof &smof &smof;
array emof &emof &emof &emof &emof &emof &emof &emof;
/* use the self-employed gap information if it is a self-employed job.
gap dates now include both self- and regular employment*/
do over sbgdy;
if sbgdy>-4 then bgdy = sbgdy;
if sbgmo>-4 then bgmo = sbgmo;
if sbgyr>-4 then bgyr = sbgyr;
if segdy>-4 then egdy = segdy;
if segmo>-4 then egmo = segmo;
if segyr>-4 then egyr = segyr;
end;
/* Missing gap days (start and stop) are now imputed to 1.
Impute start/stop dates if only day is missing.*/
do over bgyr;
if bgyr>0 then do;
if bgmo>0 and bgdy<=0 then bgdy=1;
if bgyr=stary and bgmo=starm and bgdy<stard then bgdy=stard;
end;
end;
do over egyr;
if egyr>0 then do;
if egmo>0 and egdy<=0 then egdy=1;
if egyr=stopy and egmo=stopm and egdy>stopd then egdy=stopd;
end;
end;
/*Set flag for job with gap that has invalid dates*/
do over bgyr;
if milflag ne 1 and ((-4 < bgmo < 0) or (-4 < bgyr <0)) then bgfl=1;
if milflag ne 1 and ((-4 < egyr < 0) or (-4 < egmo < 0)) then egfl=1;
end;
array _bgmdy &_BGMDY_01 &_BGMDY_02 &_BGMDY_03 &_BGMDY_04 &_BGMDY_05 &_BGMDY_06
&_BGMDY_07;
array _egmdy &_EGMDY_01 &_EGMDY_02 &_EGMDY_03 &_EGMDY_04 &_EGMDY_05 &_EGMDY_06
&_EGMDY_07;
array _gdays &_gdays_01 &_gdays_02 &_gdays_03 &_gdays_04 &_gdays_05 &_gdays_06
&_gdays_07;
array _bgap &BGAP_01 &BGAP_02 &BGAP_03 &BGAP_04 &BGAP_05 &BGAP_06
&BGAP_07;
array _egap &EGAP_01 &EGAP_02 &EGAP_03 &EGAP_04 &EGAP_05 &EGAP_06
&EGAP_07;
begmdy=mdy(01,01,1980);
dlimdy=mdy(dli_m,dli_d,dli_y);
do over bgyr;
if milflag ne 1 and uid ge 9701 then do;
/*Count the number of days from January 1, 1960 (=0), to the gap begin and end
dates.*/
if bgmo>0 and bgdy>0 and bgyr>1979 then _bgmdy=mdy(bgmo,bgdy,bgyr);
/*Fill missing gap begin day with 1*/
if bgmo>0 and bgdy in (-1,-2,-3) and bgyr>1979 then _bgmdy=mdy(bgmo,1,bgyr);
if egmo>0 and egdy>0 and egyr>1979 then _egmdy=mdy(egmo,egdy,egyr);
/*Fill missing gap end day with 1*/
if egmo>0 and egdy in (-1,-2,-3) and egyr>1979 then _egmdy=mdy(egmo,1,egyr);
/*And count the number of days in the gap*/
if _egmdy>0 and _bgmdy>0 then _gdays=_egmdy-_bgmdy+1;
/* The following line omits gap start and stop dates for gaps less than one
work week (5 days) */
if _gdays ne . and _gdays<5 then do; _bgap=.; _egap=.; end;
/*Count the number of weeks from Jan 1 1980 to gap begin week
and to gap end week to set the week numbers*/
if _bgmdy>0 then _bgap=intck('week',begmdy,_bgmdy)+1;
if _egmdy>0 then _egap =intck('week',begmdy,_egmdy)+1;
/*Recode the gap begin week and the gap end week to eliminate partial weeks
working*/
if _egap>_bgap+1 then _bgap=_bgap+1;
if _egap>_bgap then _egap=_egap-1;
/* The following line omits gap start and stop dates for gaps less than one
work week (5 days) */
if _gdays ne . and _gdays<5 then do; _bgap=.; _egap=.; end;
*A gap that starts before the job starts or ends after the job ends is reset;
if _bgap>0 and starw>0 and _bgap<starw then _bgap=starw;
if _egap>0 and stopw>0 and _egap>stopw then _egap=stopw;
/* an entire gap before dli week will be disregarded,
a gap begin before dli is reset to dli. */
if _bgap>0 and _bgmdy<dlimdy and _egmdy>dlimdy and _gdays>4 then _bgap=dliwk;
if _egap>0 and _egmdy<dlimdy then do; _bgap=.; _egap=.; end;
/* A gap that ends on/after the interview week is reset to the interview week.
*/
if _egap ge r9int then _egap=r9int;
end;
end;
run;
data emp_countweeks;
merge two emp_bday emp_int emp_week emp_gaps; by idcode; if r9int>-5;
array job1wks (i) _1-_730 w1_731-w1_1388;
array job2wks (i) _1-_730 w2_731-w2_1388;
array job3wks (i) _1-_730 w3_731-w3_1388;
array job4wks (i) _1-_730 w4_731-w4_1388;
array job5wks (i) _1-_730 w5_731-w5_1388;
array job6wks (i) _1-_730 w6_731-w6_1388;
array job7wks (i) _1-_730 w7_731-w7_1388;
array job8wks (i) _1-_730 w8_731-w8_1388;
array job9wks (i) _1-_730 w9_731-w9_1388;
/* Define rd9wk as the maximum of dliwk and age14wk. This is used for missing
start/stop weeks. */
if dliwk>0 then do;
if dliwk>age14wk then do;
rd9wk=dliwk;
end;
if age14wk=>dliwk then do;
rd9wk=age14wk;
end;
end;
*** TOTAL WEEKS WORKED;
array starf starf_1-starf_9;
array stopf stopf_1-stopf_9;
array starw &starw;
array stopw &stopw;
array stary &R9STAY;
array stopy &R9STOY;
array smof &smof;
array emof &emof;
array bself bself01-bself09;
array endwk endwk01-endwk09;
array begwk begwk01-begwk09;
array bweek1 &bgap_01;
array eweek1 &egap_01;
array bflag1 &bgfl_01;
array eflag1 &egfl_01;
array bweek2 &bgap_02;
array eweek2 &egap_02;
array bflag2 &bgfl_02;
array eflag2 &egfl_02;
array bweek3 &bgap_03;
array eweek3 &egap_03;
array bweek4 &bgap_04;
array eweek4 &egap_04;
array bweek5 &bgap_05;
array eweek5 &egap_05;
array bweek6 &bgap_06;
array eweek6 &egap_06;
array bweek7 &bgap_07;
array eweek7 &egap_07;
array milflag &R9mil;
array jobwks job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks
job9wks;
do over starf;
if milflag=1 then do; starw=.; stopw=.; end;
if starw=-3 then do; starw=rd9wk; starf=1; end;
if stopw=-3 then do; stopw=r9int-1; stopf=1; end; *using week before intwk;
if starw ne . and smof=1 and bself ne 1 then do; starf=1;
if stary=1980 then begwk=52;
if stary=1981 then begwk=104;
if stary=1982 then begwk=156;
if stary=1983 then begwk=209;
if stary=1984 then begwk=261;
if stary=1985 then begwk=313;
if stary=1986 then begwk=365;
if stary=1987 then begwk=417;
if stary=1988 then begwk=470;
if stary=1989 then begwk=522;
if stary=1990 then begwk=574;
if stary=1991 then begwk=626;
if stary=1992 then begwk=678;
if stary=1993 then begwk=730;
if stary=1994 then begwk=783;
if stary=1995 then begwk=835;
if stary=1996 then begwk=887;
if stary=1997 then begwk=939;
if stary=1998 then begwk=991;
if stary=1999 then begwk=1043;
if stary=2000 then begwk=1096;
if stary=2001 then begwk=1148;
if stary=2002 then begwk=1200;
if stary=2003 then begwk=1252;
if stary=2004 then begwk=1304;
if stary=2005 then begwk=1357;
if stary=2006 then begwk=1409;
end;
if stopw ne . and emof=1 then do; stopf=1;
if stopy=1980 then endwk=1;
if stopy=1981 then endwk=53;
if stopy=1982 then endwk=105;
if stopy=1983 then endwk=157;
if stopy=1984 then endwk=210;
if stopy=1985 then endwk=262;
if stopy=1986 then endwk=314;
if stopy=1987 then endwk=366;
if stopy=1988 then endwk=418;
if stopy=1989 then endwk=471;
if stopy=1990 then endwk=523;
if stopy=1991 then endwk=575;
if stopy=1992 then endwk=627;
if stopy=1993 then endwk=679;
if stopy=1994 then endwk=731;
if stopy=1995 then endwk=784;
if stopy=1996 then endwk=836;
if stopy=1997 then endwk=888;
if stopy=1998 then endwk=940;
if stopy=1999 then endwk=992;
if stopy=2000 then endwk=1044;
if stopy=2001 then endwk=1097;
if stopy=2002 then endwk=1149;
if stopy=2003 then endwk=1201;
if stopy=2004 then endwk=1253;
if stopy=2005 then endwk=1305;
if stopy=2006 then endwk=1358;
end;
end;
do over starw;
do i=1 to 1388;
jobwks=0;
end;
if starw>0 and stopw>0 then do;
do i=(starw) to (stopw);
jobwks=1;
end; end; end;
do over bweek1;
if bweek1>0 and eweek1>0 then do;
do i=(bweek1) to (eweek1);
jobwks=0;
end; end;
*Note no cases with a flagged gapend have a later gap;
if starw ne . and bflag1=1 and eweek1>0 then do;
do i=(starw) to (eweek1);
jobwks=-3;
end; end;
if stopw ne . and bweek1>0 and eflag1=1 then do;
do i=(bweek1) to (stopw);
jobwks=-3;
end; end;
if starw ne . and bflag1=1 and eflag1=1 then do;
do i=(starw) to (stopw);
jobwks=-3;
end; end;
if bweek2>0 and eweek2>0 then do;
do i=(bweek2) to (eweek2);
jobwks=0;
end; end;
if starw ne . and bflag2=1 and eweek2>0 then do;
do i=(starw) to (eweek2);
jobwks=-3;
end; end;
if stopw ne . and bweek2>0 and eflag2=1 then do;
do i=(bweek2) to (stopw);
jobwks=-3;
end; end;
if starw ne . and bflag2=1 and eflag2=1 then do;
do i=(starw) to (stopw);
jobwks=-3;
end; end;
if bweek3>0 & eweek3>0 then do;
do i=(bweek3) to (eweek3);
jobwks=0;
end; end;
if bweek4>0 & eweek4>0 then do;
do i=(bweek4) to (eweek4);
jobwks=0;
end; end;
if bweek5>0 & eweek5>0 then do;
do i=(bweek5) to (eweek5);
jobwks=0;
end; end;
if bweek6>0 & eweek6>0 then do;
do i=(bweek6) to (eweek6);
jobwks=0;
end; end;
if bweek7>0 & eweek7>0 then do;
do i=(bweek7) to (eweek7);
jobwks=0;
end; end;
end;
do over starf;
if starf=1 then do;
do i=(starw) to min(stopw,begwk,bweek1-1,bweek2-1,eweek1+1,eweek2+1);
jobwks=-3;
end; end;
if stopf=1 then do;
do i=max(starw,endwk,bweek1-1,bweek2-1,eweek1+1,eweek2+1) to (stopw);
jobwks=-3;
end; end;
end;
drop _1-_730;
run;
data emp29_numwks
(keep=idcode r9wks80-r9wks99 r9wks00-r9wks06
r9swks80-r9swks99 r9swks00-r9swks06
r9ewks80-r9ewks99 r9ewks00-r9ewks06
wks731-wks1388 swks731-swks1388 ewks731-ewks1388);
merge two emp_bday emp_int emp_week emp_countweeks;
by idcode; if r9int ne -5;
*********************************************************************
** Number of weeks worked during 19xx/20xx **
*********************************************************************
** This variable is created for each individual for each year of potential work activity (1980-
** 2006). Respondents not working in a given year are assigned a default value of zero weeks.
** Otherwise, the variable is the actual cumulative weeks worked on all jobs in
that year.
**
** Variables created: r9wks80- r9wks06
** r9swks80-r9swks06
** r9ewks80-r9ewks06
*********************************************************************;
array job1wks (i) _1-_730 w1_731-w1_1388;
array job2wks (i) _1-_730 w2_731-w2_1388;
array job3wks (i) _1-_730 w3_731-w3_1388;
array job4wks (i) _1-_730 w4_731-w4_1388;
array job5wks (i) _1-_730 w5_731-w5_1388;
array job6wks (i) _1-_730 w6_731-w6_1388;
array job7wks (i) _1-_730 w7_731-w7_1388;
array job8wks (i) _1-_730 w8_731-w8_1388;
array job9wks (i) _1-_730 w9_731-w9_1388;
array alljobs (i) _1-_730 wks731-wks1388;
array selfjobs (i) _1-_730 swks731-swks1388;
array empjobs (i) _1-_730 ewks731-ewks1388;
array self &R9sel;
array jobwks job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks
job9wks;
*******************************************************
** Overlay multiple jobs over work weeks **
*******************************************************;
do i=1 to 1388;
alljobs=0; selfjobs=0; empjobs=0;
end;
do over self;
do i=1 to 1388;
if jobwks=1 then alljobs=jobwks;
if jobwks=1 and self=1 then selfjobs=jobwks;
if jobwks=1 and self=0 then empjobs=jobwks;
if jobwks=-3 and alljobs=0 then alljobs=jobwks;
if jobwks=-3 and selfjobs=0 and self=1 then selfjobs=jobwks;
if jobwks=-3 and empjobs=0 and self=0 then empjobs=jobwks;
end;
end;
**********************************************************
** Calculate cumulative weeks on all jobs for each year **
**********************************************************;
array r9wks r9wks80-r9wks99 r9wks00- r9wks06;
array r9swks r9swks80-r9swks99 r9swks00-r9swks06;
array r9ewks r9ewks80-r9ewks99 r9ewks00-r9ewks06;
/* Initialize each annual c.v. */
do over r9wks;
r9wks=0;
r9swks=0;
r9ewks=0;
end;
/* 1994 */
do i=731 to 783;
if alljobs=1 then r9wks94=r9wks94+1;
if selfjobs=1 then r9swks94=r9swks94+1;
if empjobs=1 then r9ewks94=r9ewks94+1;
end;
do i=731 to 783;
if alljobs=-3 then r9wks94=-3;
if selfjobs=-3 then r9swks94=-3;
if empjobs=-3 then r9ewks94=-3;
end;
/* 1995 */
do i=784 to 835;
if alljobs=1 then r9wks95=r9wks95+1;
if selfjobs=1 then r9swks95=r9swks95+1;
if empjobs=1 then r9ewks95=r9ewks95+1;
end;
do i=784 to 835;
if alljobs=-3 then r9wks95=-3;
if selfjobs=-3 then r9swks95=-3;
if empjobs=-3 then r9ewks95=-3;
end;
/* 1996 */
do i=836 to 887;
if alljobs=1 then r9wks96=r9wks96+1;
if selfjobs=1 then r9swks96=r9swks96+1;
if empjobs=1 then r9ewks96=r9ewks96+1;
end;
do i=836 to 887;
if alljobs=-3 then r9wks96=-3;
if selfjobs=-3 then r9swks96=-3;
if empjobs=-3 then r9ewks96=-3;
end;
/* 1997 */
do i=888 to 939;
if alljobs=1 then r9wks97=r9wks97+1;
if selfjobs=1 then r9swks97=r9swks97+1;
if empjobs=1 then r9ewks97=r9ewks97+1;
end;
do i=888 to 939;
if alljobs=-3 then r9wks97=-3;
if selfjobs=-3 then r9swks97=-3;
if empjobs=-3 then r9ewks97=-3;
end;
/* 1998 */
do i=940 to 991;
if alljobs=1 then r9wks98=r9wks98+1;
if selfjobs=1 then r9swks98=r9swks98+1;
if empjobs=1 then r9ewks98=r9ewks98+1;
end;
do i=940 to 991;
if alljobs=-3 then r9wks98=-3;
if selfjobs=-3 then r9swks98=-3;
if empjobs=-3 then r9ewks98=-3;
end;
/* 1999 */
do i=992 to 1043;
if alljobs=1 then r9wks99=r9wks99+1;
if selfjobs=1 then r9swks99=r9swks99+1;
if empjobs=1 then r9ewks99=r9ewks99+1;
end;
do i=992 to 1043;
if alljobs=-3 then r9wks99=-3;
if selfjobs=-3 then r9swks99=-3;
if empjobs=-3 then r9ewks99=-3;
end;
/* 2000 */
do i=1044 to 1096;
if alljobs=1 then r9wks00=r9wks00+1;
if selfjobs=1 then r9swks00=r9swks00+1;
if empjobs=1 then r9ewks00=r9ewks00+1;
end;
do i=1044 to 1096;
if alljobs=-3 then r9wks00=-3;
if selfjobs=-3 then r9swks00=-3;
if empjobs=-3 then r9ewks00=-3;
end;
/* 2001 */
do i=1097 to 1148;
if alljobs=1 then r9wks01=r9wks01+1;
if selfjobs=1 then r9swks01=r9swks01+1;
if empjobs=1 then r9ewks01=r9ewks01+1;
end;
do i=1097 to 1148;
if alljobs=-3 then r9wks01=-3;
if selfjobs=-3 then r9swks01=-3;
if empjobs=-3 then r9ewks01=-3;
end;
/* 2002 */
do i=1149 to 1200;
if alljobs=1 then r9wks02=r9wks02+1;
if selfjobs=1 then r9swks02=r9swks02+1;
if empjobs=1 then r9ewks02=r9ewks02+1;
end;
do i=1149 to 1200;
if alljobs=-3 then r9wks02=-3;
if selfjobs=-3 then r9swks02=-3;
if empjobs=-3 then r9ewks02=-3;
end;
/* 2003 */
do i=1201 to 1252;
if alljobs=1 then r9wks03=r9wks03+1;
if selfjobs=1 then r9swks03=r9swks03+1;
if empjobs=1 then r9ewks03=r9ewks03+1;
end;
do i=1201 to 1252;
if alljobs=-3 then r9wks03=-3;
if selfjobs=-3 then r9swks03=-3;
if empjobs=-3 then r9ewks03=-3;
end;
/* 2004 */
do i=1253 to 1304;
if alljobs=1 then r9wks04=r9wks04+1;
if selfjobs=1 then r9swks04=r9swks04+1;
if empjobs=1 then r9ewks04=r9ewks04+1;
end;
do i=1253 to 1304;
if alljobs=-3 then r9wks04=-3;
if selfjobs=-3 then r9swks04=-3;
if empjobs=-3 then r9ewks04=-3;
end;
/* 2005 */
do i=1305 to 1357;
if alljobs=1 then r9wks05=r9wks05+1;
if selfjobs=1 then r9swks05=r9swks05+1;
if empjobs=1 then r9ewks05=r9ewks05+1;
end;
do i=1305 to 1357;
if alljobs=-3 then r9wks05=-3;
if selfjobs=-3 then r9swks05=-3;
if empjobs=-3 then r9ewks05=-3;
end;
/* 2006 */
do i=1358 to 1388;
if alljobs=1 then r9wks06=r9wks06+1;
if selfjobs=1 then r9swks06=r9swks06+1;
if empjobs=1 then r9ewks06=r9ewks06+1;
end;
do i=1358 to 1388;
if alljobs=-3 then r9wks06=-3;
if selfjobs=-3 then r9swks06=-3;
if empjobs=-3 then r9ewks06=-3;
end;
proc means n mean min max;
*var idcode r9wks80-r9wks99 r9wks00-r9wks06 r9swks80-r9swks99 r9swks00-r9swks06
r9ewks80-r9ewks99 r9ewks00-r9ewks06
wks1200-wks1388 swks1250-swks1388 ewks1250-ewks1388;
title2 'Emp29_numwks';
run;
data emp30_totwks(keep=idcode allwks selfwks empwks);
merge two emp_bday emp_int emp_week
emp29_numwks(keep=idcode wks731-wks1388 swks731-swks1388 ewks731-ewks1388); by
idcode;
if r9int ne -5;
*********************************************************************************
** Number of weeks worked at any job since last interview date **
** Variables created: allwks, empwks, selfwks **
*********************************************************************************;
array alljobs (i) _1-_730 wks731-wks1388;
array selfjobs (i) _1-_730 swks731-swks1388;
array empjobs (i) _1-_730 ewks731-ewks1388;
** Calculate cumulative weeks on all jobs since dli;
allwks=0;
selfwks=0;
empwks=0;
if dliwk>0 then do;
if dliwk=>age14wk then do;
do i=dliwk to 1388;
if alljobs=1 then do;
allwks=allwks+1;
end;
if selfjobs=1 then do;
selfwks=selfwks+1;
end;
if empjobs=1 then do;
empwks=empwks+1;
end;
end;
do i=dliwk to 1388;
if alljobs=-3 then do;
allwks=-3;
end;
if selfjobs=-3 then do;
selfwks=-3;
end;
if empjobs=-3 then do;
empwks=-3;
end;
end;
end;
if age14wk>dliwk then do;
do i=age14wk to 1388;
if alljobs=1 then do;
allwks=allwks+1;
end;
if selfjobs=1 then do;
selfwks=selfwks+1;
end;
if empjobs=1 then do;
empwks=empwks+1;
end;
end;
do i=age14wk to 1388;
if alljobs=-3 then do;
allwks=-3;
end;
if selfjobs=-3 then do;
selfwks=-3;
end;
if empjobs=-3 then do;
empwks=-3;
end;
end;
end;
end;
proc means n mean min max; var idcode allwks selfwks empwks;
title2 'Emp30_totwks';
run;
data emp31_jobwks(keep=idcode r9w80_1 -- r9w06_9);
merge emp_int emp_countweeks; by idcode; if r9int ne -5;
** Number of weeks worked at each current job each year
** For example: r9w93_3 gives the number of weeks worked in 1993 on job3 from
round9;
array job1wks (i) _1-_730 w1_731-w1_1388;
array job2wks (i) _1-_730 w2_731-w2_1388;
array job3wks (i) _1-_730 w3_731-w3_1388;
array job4wks (i) _1-_730 w4_731-w4_1388;
array job5wks (i) _1-_730 w5_731-w5_1388;
array job6wks (i) _1-_730 w6_731-w6_1388;
array job7wks (i) _1-_730 w7_731-w7_1388;
array job8wks (i) _1-_730 w8_731-w8_1388;
array job9wks (i) _1-_730 w9_731-w9_1388;
array r9wks80 r9w80_1-r9w80_9;
array r9wks81 r9w81_1-r9w81_9;
array r9wks82 r9w82_1-r9w82_9;
array r9wks83 r9w83_1-r9w83_9;
array r9wks84 r9w84_1-r9w84_9;
array r9wks85 r9w85_1-r9w85_9;
array r9wks86 r9w86_1-r9w86_9;
array r9wks87 r9w87_1-r9w87_9;
array r9wks88 r9w88_1-r9w88_9;
array r9wks89 r9w89_1-r9w89_9;
array r9wks90 r9w90_1-r9w90_9;
array r9wks91 r9w91_1-r9w91_9;
array r9wks92 r9w92_1-r9w92_9;
array r9wks93 r9w93_1-r9w93_9;
array r9wks94 r9w94_1-r9w94_9;
array r9wks95 r9w95_1-r9w95_9;
array r9wks96 r9w96_1-r9w96_9;
array r9wks97 r9w97_1-r9w97_9;
array r9wks98 r9w98_1-r9w98_9;
array r9wks99 r9w99_1-r9w99_9;
array r9wks00 r9w00_1-r9w00_9;
array r9wks01 r9w01_1-r9w01_9;
array r9wks02 r9w02_1-r9w02_9;
array r9wks03 r9w03_1-r9w03_9;
array r9wks04 r9w04_1-r9w04_9;
array r9wks05 r9w05_1-r9w05_9;
array r9wks06 r9w06_1-r9w06_9;
array jobwks job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks
job9wks;
*****************************************************************
** Calculate cumulative weeks on individual jobs for each year **
** No jobs in 2005 begin before 1994 **
*****************************************************************;
do over r9wks80; r9wks80=0; end;
do over r9wks81; r9wks81=0; end;
do over r9wks82; r9wks82=0; end;
do over r9wks83; r9wks83=0; end;
do over r9wks84; r9wks84=0; end;
do over r9wks85; r9wks85=0; end;
do over r9wks86; r9wks86=0; end;
do over r9wks87; r9wks87=0; end;
do over r9wks88; r9wks88=0; end;
do over r9wks89; r9wks89=0; end;
do over r9wks90; r9wks90=0; end;
do over r9wks91; r9wks91=0; end;
do over r9wks92; r9wks92=0; end;
do over r9wks93; r9wks93=0; end;
/* 1994 */
do over r9wks94; r9wks94=0;
do i=731 to 783; if jobwks=1 then r9wks94=r9wks94+1; end;
do i=731 to 783; if jobwks=-3 then r9wks94=-3; end;
end;
/* 1995 */
do over r9wks95; r9wks95=0;
do i=784 to 835; if jobwks=1 then r9wks95=r9wks95+1; end;
do i=784 to 835; if jobwks=-3 then r9wks95=-3; end;
end;
/* 1996 */
do over r9wks96; r9wks96=0;
do i=836 to 887; if jobwks=1 then r9wks96=r9wks96+1; end;
do i=836 to 887; if jobwks=-3 then r9wks96=-3; end;
end;
/* 1997 */
do over r9wks97; r9wks97=0;
do i=888 to 939; if jobwks=1 then r9wks97=r9wks97+1; end;
do i=888 to 939; if jobwks=-3 then r9wks97=-3; end;
end;
/* 1998 */
do over r9wks98; r9wks98=0;
do i=940 to 991; if jobwks=1 then r9wks98=r9wks98+1; end;
do i=940 to 991; if jobwks=-3 then r9wks98=-3; end;
end;
/* 1999 */
do over r9wks99; r9wks99=0;
do i=992 to 1043; if jobwks=1 then r9wks99=r9wks99+1; end;
do i=992 to 1043; if jobwks=-3 then r9wks99=-3; end;
end;
/* 2000 */
do over r9wks00; r9wks00=0;
do i=1044 to 1096; if jobwks=1 then r9wks00=r9wks00+1; end;
do i=1044 to 1096; if jobwks=-3 then r9wks00=-3; end;
end;
/* 2001 */
do over r9wks01; r9wks01=0;
do i=1097 to 1148; if jobwks=1 then r9wks01=r9wks01+1; end;
do i=1097 to 1148; if jobwks=-3 then r9wks01=-3; end;
end;
/* 2002 */
do over r9wks02; r9wks02=0;
do i=1149 to 1200; if jobwks=1 then r9wks02=r9wks02+1; end;
do i=1149 to 1200; if jobwks=-3 then r9wks02=-3; end;
end;
/* 2003 */
do over r9wks03; r9wks03=0;
do i=1201 to 1252; if jobwks=1 then r9wks03=r9wks03+1; end;
do i=1201 to 1252; if jobwks=-3 then r9wks03=-3; end;
end;
/* 2004 */
do over r9wks04; r9wks04=0;
do i=1253 to 1304; if jobwks=1 then r9wks04=r9wks04+1; end;
do i=1253 to 1304; if jobwks=-3 then r9wks04=-3; end;
end;
/* 2005 */
do over r9wks05; r9wks05=0;
do i=1305 to 1357; if jobwks=1 then r9wks05=r9wks05+1; end;
do i=1305 to 1357; if jobwks=-3 then r9wks05=-3; end;
end;
/* 2006 */
do over r9wks06; r9wks06=0;
do i=1358 to 1388; if jobwks=1 then r9wks06=r9wks06+1; end;
do i=1358 to 1388; if jobwks=-3 then r9wks06=-3; end;
end;
proc means n mean min max;
var idcode
r9w94_1-r9w94_9 r9w95_1-r9w95_9 r9w96_1-r9w96_9
r9w97_1-r9w97_9 r9w98_1-r9w98_9 r9w99_1-r9w99_9
r9w00_1-r9w00_9 r9w01_1-r9w01_9 r9w02_1-r9w02_9
r9w03_1-r9w03_9 r9w04_1-r9w04_9 r9w05_1-r9w05_9
r9w06_1-r9w06_9;
title2 'Emp31_jobwks';
run;
data emp32_jobten (keep=idcode r9ten1-r9ten9);
merge emp_int emp_countweeks; by idcode; if r9int ne -5;
** Total tenure at each current job as of survey date;
array job1wks (i) _1-_730 w1_731-w1_1388;
array job2wks (i) _1-_730 w2_731-w2_1388;
array job3wks (i) _1-_730 w3_731-w3_1388;
array job4wks (i) _1-_730 w4_731-w4_1388;
array job5wks (i) _1-_730 w5_731-w5_1388;
array job6wks (i) _1-_730 w6_731-w6_1388;
array job7wks (i) _1-_730 w7_731-w7_1388;
array job8wks (i) _1-_730 w8_731-w8_1388;
array job9wks (i) _1-_730 w9_731-w9_1388;
array r9ten r9ten1-r9ten9;
array jobwks job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks
job9wks;
do over r9ten; r9ten=0;
do i=1 to 1388;
if jobwks=1 then r9ten=r9ten+1;
end;
end;
do over r9ten;
do i=1 to 1388;
if jobwks=-3 then r9ten=-3;
end;
end;
proc means n mean min max; var idcode r9ten1-r9ten9;
title2 'Emp32_jobten';
run;
data emp33_anhours (keep=idcode r9hrs80-r9hrs99 r9hrs00-r9hrs06
r9shrs80-r9shrs99 r9shrs00-r9shrs06
r9ehrs80-r9ehrs99 r9ehrs00-r9ehrs06 hours01-hours09);
merge two emp_int emp_week emp31_jobwks; by idcode;
if r9int ne -5;
** Total hours worked each year on all current, current self, and current emp
jobs **
** Eg: r9shrs99 is total hours worked on all current self employed jobs in 1999;
array starw (k) starw01- starw09;
array stopw (k) stopw01- stopw09;
array rghrsb (k) rghrsb01- rghrsb09;
array rghrs (k) rghrs01- rghrs09;
array othrs (k) othrs01- othrs09;
array hours (k) hours01- hours09;
array e23901 (k) &E23901;
array e24501 (k) &E24501;
array e34402 (k) &E34402;
array e34403 (k) &E34403;
array e34428 (k) &E34428;
array e37904 (k) &E37904;
array e38000b (k) &E38000B;
array e38000f (k) &E38000F;
array e38002 (k) &E38002;
array e38102 (k) &E38102;
array e38103 (k) &E38103;
array e38105 (k) &E38105;
array e59901 (k) &E59901;
array e88000 (k) &E88000;
array e88501 (k) &E88501;
array e98402 (k) &E98402;
array e98403 (k) &E98403;
array e98429 (k) &E98429;
array e1002252 (k) &E1002252;
array e100231 (k) &E10023102;
array e1002253 (k) &E1002253;
array e100232 (k) &E10023203;
array e226042 (k) &E226042;
array e22610 (k) &E2261002;
array e226043 (k) &E226043;
array e22611 (k) &E2261103;
***** Initialize the number of hours per week to 0;
do k=1 to 9;
rghrsb=0;
rghrs=0;
othrs=0;
hours=0;
end;
***** Regular rghrs Per Week;
do k=1 to 9;
if e23901 not in (.,-4,-5) then rghrsb=e23901;
if e34402 not in (.,-4,-5) then rghrsb=e34402;
if e34428 not in (.,-4,-5) then rghrsb=e34428;
if e22610 not in (.,-4,-5) then rghrsb=e22610;
else if e226042 lt 0 and e226042 not in (.,-4,-5) then rghrsb=-3;
if e88000 not in (.,-4,-5) then rghrsb=e88000;
if e98402 not in (.,-4,-5) then rghrsb=e98402;
if e98429 not in (.,-4,-5) then rghrsb=e98429;
if e100231 not in (.,-4,-5) then rghrsb=e100231;
else if e1002252 lt 0 and e1002252 not in (.,-4,-5) then rghrsb=-3;
if e38000f not in (.,-4,-5) then rghrsb=e38000f;
if e38002 in (.,-4,0) then rghrs=rghrsb;
else if e38002 lt 0 and e38002 ne -5 then rghrs=-3;
else if e38002 gt 0 then do;
if rghrsb gt 0 then rghrs=rghrsb-e38002;
else rghrs=-3;
end;
if e38000b lt 0 and e38000b not in (-4,-5,.) then rghrs=-3;
if e38102 in (1,3) and e38103 not in (.,-4,-5) then rghrs=e38103;
if e38102 lt 0 and e38102 not in (-4,-5, .) then rghrs=-3;
if e37904 > -4 then rghrs=e37904;
if e59901 > -4 then rghrs=e59901;
end;
***** Overtime Hours Per Week;
do k=1 to 9;
if e24501 not in (.,-4,-5) then othrs=e24501;
if e34403 not in (.,-4,-5) then othrs=e34403;
if e22611 not in (.,-4,-5) then othrs=e22611;
else if e226043 lt 0 and e226043 not in (.,-4,-5) then othrs=-3;
if e88501 not in (.,-4,-5) then othrs=e88501;
if e98403 not in (.,-4,-5) then othrs=e98403;
if e100232 not in (.,-4,-5) then othrs=e100232;
else if e1002253 lt 0 and e1002253 not in (.,-4,-5) then othrs=-3;
if e38002 not in (.,-4,-5) then othrs=e38002;
if e38105 not in (.,-4,-5) then othrs=e38105;
else if e38102 lt 0 and e38102 not in (.,-4,-5) then othrs=-3;
end;
***** Total Hours Per Week;
do k=1 to 9;
if rghrs in (-1,-2,-3) or othrs in (-1,-2,-3) then hours=-3;
else if rghrs ge 0 and othrs ge 0 then hours=rghrs + othrs;
end;
*****************************************************************
** Calculate cumulative hours on individual jobs for each year **
*****************************************************************;
array self (k) &R9sel;
* total hours worked in the year;
r9hrs80=0; r9shrs80=0; r9ehrs80=0;
r9hrs81=0; r9shrs81=0; r9ehrs81=0;
r9hrs82=0; r9shrs82=0; r9ehrs82=0;
r9hrs83=0; r9shrs83=0; r9ehrs83=0;
r9hrs84=0; r9shrs84=0; r9ehrs84=0;
r9hrs85=0; r9shrs85=0; r9ehrs85=0;
r9hrs86=0; r9shrs86=0; r9ehrs86=0;
r9hrs87=0; r9shrs87=0; r9ehrs87=0;
r9hrs88=0; r9shrs88=0; r9ehrs88=0;
r9hrs89=0; r9shrs89=0; r9ehrs89=0;
r9hrs90=0; r9shrs90=0; r9ehrs90=0;
r9hrs91=0; r9shrs91=0; r9ehrs91=0;
r9hrs92=0; r9shrs92=0; r9ehrs92=0;
r9hrs93=0; r9shrs93=0; r9ehrs93=0;
/* 1994 */
* weeks worked on each job;
array wks94 (k) r9w94_1-r9w94_9;
* hours/week worked on each job;
array ah94 (k) ah94_1-ah94_9;
array sah94 (k) sah94_1-sah94_9;
array eah94 (k) eah94_1-eah94_9;
do k=1 to 9;
ah94=0;
sah94=0;
eah94=0;
end;
do k=1 to 9;
if hours ge 0 and wks94 ge 0 then ah94=hours*wks94;
else if wks94=-3 or (hours in (-1,-2,-3) and wks94 ne 0) then ah94=-3;
if self=1 then sah94=ah94;
if self=0 then eah94=ah94;
end;
* total hours worked in the year;
r9hrs94=0;
r9shrs94=0;
r9ehrs94=0;
do k=1 to 9;
if ah94 ge 0 then r9hrs94 = r9hrs94 + ah94;
if sah94 ge 0 then r9shrs94 = r9shrs94 + sah94;
if eah94 ge 0 then r9ehrs94 = r9ehrs94 + eah94;
end;
do k=1 to 9;
if ah94=-3 then r9hrs94 = -3;
if sah94=-3 then r9shrs94 = -3;
if eah94=-3 then r9ehrs94 = -3;
end;
/* 1995 */
* weeks worked on each job;
array wks95 (k) r9w95_1-r9w95_9;
* hours worked on each job;
array ah95 (k) ah95_1-ah95_9;
array sah95 (k) sah95_1-sah95_9;
array eah95 (k) eah95_1-eah95_9;
do k=1 to 9;
ah95=0;
sah95=0;
eah95=0;
end;
do k=1 to 9;
if hours ge 0 and wks95 ge 0 then ah95=hours*wks95;
else if wks95=-3 or (hours in (-1,-2,-3) and wks95 ne 0) then ah95=-3;
if self=1 then sah95=ah95;
if self=0 then eah95=ah95;
end;
* total hours worked in the year;
r9hrs95=0;
r9shrs95=0;
r9ehrs95=0;
do k=1 to 9;
if ah95 ge 0 then r9hrs95 = r9hrs95 + ah95;
if sah95 ge 0 then r9shrs95 = r9shrs95 + sah95;
if eah95 ge 0 then r9ehrs95 = r9ehrs95 + eah95;
end;
do k=1 to 9;
if ah95=-3 then r9hrs95 = -3;
if sah95=-3 then r9shrs95 = -3;
if eah95=-3 then r9ehrs95 = -3;
end;
/* 1996 */
* weeks worked on each job;
array wks96 (k) r9w96_1-r9w96_9;
* hours worked on each job;
array ah96 (k) ah96_1-ah96_9;
array sah96 (k) sah96_1-sah96_9;
array eah96 (k) eah96_1-eah96_9;
do k=1 to 9;
ah96=0;
sah96=0;
eah96=0;
end;
do k=1 to 9;
if hours ge 0 and wks96 ge 0 then ah96=hours*wks96;
else if wks96=-3 or (hours in (-1,-2,-3) and wks96 ne 0) then ah96=-3;
if self=1 then sah96=ah96;
if self=0 then eah96=ah96;
end;
* total hours worked in the year;
r9hrs96=0;
r9shrs96=0;
r9ehrs96=0;
do k=1 to 9;
if ah96 ge 0 then r9hrs96 = r9hrs96 + ah96;
if sah96 ge 0 then r9shrs96 = r9shrs96 + sah96;
if eah96 ge 0 then r9ehrs96= r9ehrs96 + eah96;
end;
do k=1 to 9;
if ah96=-3 then r9hrs96 = -3;
if sah96=-3 then r9shrs96 = -3;
if eah96=-3 then r9ehrs96 = -3;
end;
/* 1997 */
* weeks worked on each job;
array wks97 (k) r9w97_1-r9w97_9;
* hours worked on each job;
array ah97 (k) ah97_1-ah97_9;
array sah97 (k) sah97_1-sah97_9;
array eah97 (k) eah97_1-eah97_9;
do k=1 to 9;
ah97=0;
sah97=0;
eah97=0;
end;
do k=1 to 9;
if hours ge 0 and wks97 ge 0 then ah97=hours*wks97;
else if wks97=-3 or (hours in (-1,-2,-3) and wks97 ne 0) then ah97=-3;
if self=1 then sah97=ah97;
if self=0 then eah97=ah97;
end;
* total hours worked in the year;
r9hrs97=0;
r9shrs97=0;
r9ehrs97=0;
do k=1 to 9;
if ah97 ge 0 then r9hrs97 = r9hrs97 + ah97;
if sah97 ge 0 then r9shrs97 = r9shrs97 + sah97;
if eah97 ge 0 then r9ehrs97 = r9ehrs97 + eah97;
end;
do k=1 to 9;
if ah97=-3 then r9hrs97 = -3;
if sah97=-3 then r9shrs97 = -3;
if eah97=-3 then r9ehrs97 = -3;
end;
/* 1998 */
* weeks worked on each job;
array wks98 (k) r9w98_1-r9w98_9;
* hours worked on each job;
array ah98 (k) ah98_1-ah98_9;
array sah98 (k) sah98_1-sah98_9;
array eah98 (k) eah98_1-eah98_9;
do k=1 to 9;
ah98=0;
sah98=0;
eah98=0;
end;
do k=1 to 9;
if hours ge 0 and wks98 ge 0 then ah98=hours*wks98;
else if wks98=-3 or (hours in (-1,-2,-3) and wks98 ne 0) then ah98=-3;
if self=1 then sah98=ah98;
if self=0 then eah98=ah98;
end;
* total hours worked in the year;
r9hrs98=0;
r9shrs98=0;
r9ehrs98=0;
do k=1 to 9;
if ah98 ge 0 then r9hrs98 = r9hrs98 + ah98;
if sah98 ge 0 then r9shrs98 = r9shrs98 + sah98;
if eah98 ge 0 then r9ehrs98 = r9ehrs98 + eah98;
end;
do k=1 to 9;
if ah98=-3 then r9hrs98 = -3;
if sah98=-3 then r9shrs98 = -3;
if eah98=-3 then r9ehrs98 = -3;
end;
/* 1999 */
* weeks worked on each job;
array wks99 (k) r9w99_1-r9w99_9;
* hours worked on each job;
array ah99 (k) ah99_1-ah99_9;
array sah99 (k) sah99_1-sah99_9;
array eah99 (k) eah99_1-eah99_9;
do k=1 to 9;
ah99=0;
sah99=0;
eah99=0;
end;
do k=1 to 9;
if hours ge 0 and wks99 ge 0 then ah99=hours*wks99;
else if wks99=-3 or (hours in (-1,-2,-3) and wks99 ne 0) then ah99=-3;
if self=1 then sah99=ah99;
if self=0 then eah99=ah99;
end;
* total hours worked in the year;
r9hrs99=0;
r9shrs99=0;
r9ehrs99=0;
do k=1 to 9;
if ah99 ge 0 then r9hrs99 = r9hrs99 + ah99;
if sah99 ge 0 then r9shrs99 = r9shrs99 + sah99;
if eah99 ge 0 then r9ehrs99 = r9ehrs99 + eah99;
end;
do k=1 to 9;
if ah99=-3 then r9hrs99 = -3;
if sah99=-3 then r9shrs99 = -3;
if eah99=-3 then r9ehrs99 = -3;
end;
/* 2000 */
* weeks worked on each job;
array wks00 (k) r9w00_1-r9w00_9;
* hours worked on each job;
array ah00 (k) ah00_1-ah00_9;
array sah00 (k) sah00_1-sah00_9;
array eah00 (k) eah00_1-eah00_9;
do k=1 to 9;
ah00=0;
sah00=0;
eah00=0;
end;
do k=1 to 9;
if hours ge 0 and wks00 ge 0 then ah00=hours*wks00;
else if wks00=-3 or (hours in (-1,-2,-3) and wks00 ne 0) then ah00=-3;
if self=1 then sah00=ah00;
if self=0 then eah00=ah00;
end;
* total hours worked in the year;
r9hrs00=0;
r9shrs00=0;
r9ehrs00=0;
do k=1 to 9;
if ah00 ge 0 then r9hrs00 = r9hrs00 + ah00;
if sah00 ge 0 then r9shrs00 = r9shrs00 + sah00;
if eah00 ge 0 then r9ehrs00 = r9ehrs00 + eah00;
end;
do k=1 to 9;
if ah00=-3 then r9hrs00 = -3;
if sah00=-3 then r9shrs00 = -3;
if eah00=-3 then r9ehrs00 = -3;
end;
/* 2001 */
* weeks worked on each job;
array wks01 (k) r9w01_1-r9w01_9;
* hours worked on each job;
array ah01 (k) ah01_1-ah01_9;
array sah01 (k) sah01_1-sah01_9;
array eah01 (k) eah01_1-eah01_9;
do k=1 to 9;
ah01=0;
sah01=0;
eah01=0;
end;
do k=1 to 9;
if hours ge 0 and wks01 ge 0 then ah01=hours*wks01;
else if wks01=-3 or (hours in (-1,-2,-3) and wks01 ne 0) then ah01=-3;
if self=1 then sah01=ah01;
if self=0 then eah01=ah01;
end;
* total hours worked in the year;
r9hrs01=0;
r9shrs01=0;
r9ehrs01=0;
do k=1 to 9;
if ah01 ge 0 then r9hrs01 = r9hrs01 + ah01;
if sah01 ge 0 then r9shrs01 = r9shrs01 + sah01;
if eah01 ge 0 then r9ehrs01 = r9ehrs01 + eah01;
end;
do k=1 to 9;
if ah01=-3 then r9hrs01 = -3;
if sah01=-3 then r9shrs01 = -3;
if eah01=-3 then r9ehrs01 = -3;
end;
/* 2002 */
* weeks worked on each job;
array wks02 (k) r9w02_1-r9w02_9;
* hours worked on each job;
array ah02 (k) ah02_1-ah02_9;
array sah02 (k) sah02_1-sah02_9;
array eah02 (k) eah02_1-eah02_9;
do k=1 to 9;
ah02=0;
sah02=0;
eah02=0;
end;
do k=1 to 9;
if hours ge 0 and wks02 ge 0 then ah02=hours*wks02;
else if wks02=-3 or (hours in (-1,-2,-3) and wks02 ne 0) then ah02=-3;
if self=1 then sah02=ah02;
if self=0 then eah02=ah02;
end;
* total hours worked in the year;
r9hrs02=0;
r9shrs02=0;
r9ehrs02=0;
do k=1 to 9;
if ah02 ge 0 then r9hrs02 = r9hrs02 + ah02;
if sah02 ge 0 then r9shrs02 = r9shrs02 + sah02;
if eah02 ge 0 then r9ehrs02 = r9ehrs02 + eah02;
end;
do k=1 to 9;
if ah02=-3 then r9hrs02 = -3;
if sah02=-3 then r9shrs02 = -3;
if eah02=-3 then r9ehrs02 = -3;
end;
/* 2003 */
* weeks worked on each job;
array wks03 (k) r9w03_1-r9w03_9;
* hours worked on each job;
array ah03 (k) ah03_1-ah03_9;
array sah03 (k) sah03_1-sah03_9;
array eah03 (k) eah03_1-eah03_9;
do k=1 to 9;
ah03=0;
sah03=0;
eah03=0;
end;
do k=1 to 9;
if hours ge 0 and wks03 ge 0 then ah03=hours*wks03;
else if wks03=-3 or (hours in (-1,-2,-3) and wks03 ne 0) then ah03=-3;
if self=1 then sah03=ah03;
if self=0 then eah03=ah03;
end;
* total hours worked in the year;
r9hrs03=0;
r9shrs03=0;
r9ehrs03=0;
do k=1 to 9;
if ah03 ge 0 then r9hrs03 = r9hrs03 + ah03;
if sah03 ge 0 then r9shrs03 = r9shrs03 + sah03;
if eah03 ge 0 then r9ehrs03 = r9ehrs03 + eah03;
end;
do k=1 to 9;
if ah03=-3 then r9hrs03 = -3;
if sah03=-3 then r9shrs03 = -3;
if eah03=-3 then r9ehrs03 = -3;
end;
/* 2004 */
* weeks worked on each job;
array wks04 (k) r9w04_1-r9w04_9;
* hours worked on each job;
array ah04 (k) ah04_1-ah04_9;
array sah04 (k) sah04_1-sah04_9;
array eah04 (k) eah04_1-eah04_9;
do k=1 to 9;
ah04=0;
sah04=0;
eah04=0;
end;
do k=1 to 9;
if hours ge 0 and wks04 ge 0 then ah04=hours*wks04;
else if wks04=-3 or (hours in (-1,-2,-3) and wks04 ne 0) then ah04=-3;
if self=1 then sah04=ah04;
if self=0 then eah04=ah04;
end;
* total hours worked in the year;
r9hrs04=0;
r9shrs04=0;
r9ehrs04=0;
do k=1 to 9;
if ah04 ge 0 then r9hrs04 = r9hrs04 + ah04;
if sah04 ge 0 then r9shrs04 = r9shrs04 + sah04;
if eah04 ge 0 then r9ehrs04 = r9ehrs04 + eah04;
end;
do k=1 to 9;
if ah04=-3 then r9hrs04 = -3;
if sah04=-3 then r9shrs04 = -3;
if eah04=-3 then r9ehrs04 = -3;
end;
/* 2005 */
* weeks worked on each job;
array wks05 (k) r9w05_1-r9w05_9;
* hours worked on each job;
array ah05 (k) ah05_1-ah05_9;
array sah05 (k) sah05_1-sah05_9;
array eah05 (k) eah05_1-eah05_9;
do k=1 to 9;
ah05=0;
sah05=0;
eah05=0;
end;
do k=1 to 9;
if hours ge 0 and wks05 ge 0 then ah05=hours*wks05;
else if wks05=-3 or (hours in (-1,-2,-3) and wks05 ne 0) then ah05=-3;
if self=1 then sah05=ah05;
if self=0 then eah05=ah05;
end;
* total hours worked in the year;
r9hrs05=0;
r9shrs05=0;
r9ehrs05=0;
do k=1 to 9;
if ah05 ge 0 then r9hrs05 = r9hrs05 + ah05;
if sah05 ge 0 then r9shrs05 = r9shrs05 + sah05;
if eah05 ge 0 then r9ehrs05 = r9ehrs05 + eah05;
end;
do k=1 to 9;
if ah05=-3 then r9hrs05 = -3;
if sah05=-3 then r9shrs05 = -3;
if eah05=-3 then r9ehrs05 = -3;
end;
/* 2006 */
* weeks worked on each job;
array wks06 (k) r9w06_1-r9w06_9;
* hours worked on each job;
array ah06 (k) ah06_1-ah06_9;
array sah06 (k) sah06_1-sah06_9;
array eah06 (k) eah06_1-eah06_9;
do k=1 to 9;
ah06=0;
sah06=0;
eah06=0;
end;
do k=1 to 9;
if hours ge 0 and wks06 ge 0 then ah06=hours*wks06;
else if wks06=-3 or (hours in (-1,-2,-3) and wks06 ne 0) then ah06=-3;
if self=1 then sah06=ah06;
if self=0 then eah06=ah06;
end;
* total hours worked in the year;
r9hrs06=0;
r9shrs06=0;
r9ehrs06=0;
do k=1 to 9;
if ah06 ge 0 then r9hrs06 = r9hrs06 + ah06;
if sah06 ge 0 then r9shrs06 = r9shrs06 + sah06;
if eah06 ge 0 then r9ehrs06 = r9ehrs06 + eah06;
end;
do k=1 to 9;
if ah06=-3 then r9hrs06 = -3;
if sah06=-3 then r9shrs06 = -3;
if eah06=-3 then r9ehrs06 = -3;
end;
proc means n mean min max;
title2 'Emp33_anhours';
var idcode r9hrs80-r9hrs99 r9hrs00-r9hrs06 r9shrs80-r9shrs99 r9shrs00-r9shrs06
r9ehrs80-r9ehrs99 r9ehrs00-r9ehrs06 hours01-hours09;
run;
data emp34_wksage14(keep=idcode r9wks14 r9ewks14 r9wks20 r9ewks20);
merge two(keep=idcode &R9sel)
emp_bday emp_int emp29_numwks; by idcode; if r9int ne -5;
*r_ewks14 (r_wks14) is number of weeks worked at employee-type job (all jobs)
age 14 - 20;
*r_ewks20 (r_wks20) is number of weeks worked at employee-type job (all jobs)
since age 20;
array alljobs (i) _1-_730 wks731-wks1388;
array empjobs (i) _1-_730 ewks731-ewks1388;
r9ewks14=0; r9wks14=0; r9ewks20=0; r9wks20=0;
/* The min. of age14wk (age20wk) is 731 (1044).
The max. of age14wk (age20wk) is 992 (1305).
All values of age14wk (age20wk) are positive. */
/* r9wks14 */
if age14wk>0 and (age20wk-1)<=1388 then do;
do i=age14wk to (age20wk-1);
if alljobs=1 then do;
r9wks14=r9wks14+1;
end;
end;
do i=age14wk to (age20wk-1);
if alljobs=-3 then do;
r9wks14=-3;
end;
end;
end;
if age14wk>0 and (age20wk-1)>1388 then do;
do i=age14wk to 1388;
if alljobs=1 then do;
r9wks14=r9wks14+1;
end;
end;
do i=age14wk to 1388;
if alljobs=-3 then do;
r9wks14=-3;
end;
end;
end;
/* r9ewks14 */
if age14wk>0 and (age20wk-1)<=1388 then do;
do i=age14wk to (age20wk-1);
if empjobs=1 then do;
r9ewks14=r9ewks14+1;
end;
end;
do i=age14wk to (age20wk-1);
if empjobs=-3 then do;
r9ewks14=-3;
end;
end;
end;
if age14wk>0 and (age20wk-1)>1388 then do;
do i=age14wk to 1388;
if empjobs=1 then do;
r9ewks14=r9ewks14+1;
end;
end;
do i=age14wk to 1388;
if empjobs=-3 then do;
r9ewks14=-3;
end;
end;
end;
/* r9wks20 */
if age14wk>0 and age20wk<=1388 then do;
do i=age20wk to 1388;
if alljobs=1 then do;
r9wks20=r9wks20+1;
end;
end;
do i=age20wk to 1388;
if alljobs=-3 then do;
r9wks20=-3;
end;
end;
end;
/* r9ewks20 */
if age14wk>0 and age20wk<=1388 then do;
do i=age20wk to 1388;
if empjobs=1 then do;
r9ewks20=r9ewks20+1;
end;
end;
do i=age20wk to 1388;
if empjobs=-3 then do;
r9ewks20=-3;
end;
end;
end;
proc means n mean min max data=emp34_wksage14;
var idcode r9wks14 r9ewks14 r9wks20 r9ewks20;
title2 'Emp34_wksage14';
run;
data emp35_hrsage14(keep=idcode r9hrs14 r9ehrs14 r9hrs20 r9ehrs20 dliwk
end14wk);
merge two(keep=idcode &R9sel) emp_bday emp_int emp_countweeks
emp33_anhours(keep=idcode hours01-hours09); by idcode; if r9int ne -5;
array job1wks (i) _1-_730 w1_731-w1_1388;
array job2wks (i) _1-_730 w2_731-w2_1388;
array job3wks (i) _1-_730 w3_731-w3_1388;
array job4wks (i) _1-_730 w4_731-w4_1388;
array job5wks (i) _1-_730 w5_731-w5_1388;
array job6wks (i) _1-_730 w6_731-w6_1388;
array job7wks (i) _1-_730 w7_731-w7_1388;
array job8wks (i) _1-_730 w8_731-w8_1388;
array job9wks (i) _1-_730 w9_731-w9_1388;
/* Initialize created variables */
r9hrs14=0;
r9ehrs14=0;
r9hrs20=0;
r9ehrs20=0;
*wks1405 is number of weeks worked ages 14 -19 for job 5;
*hrs1405 is number of hours worked ages 14 -19 for job 5;
*ehrs1405 is number of employee-type job hours worked ages 14 -19 for job 5;
*wks2005 is number of weeks worked since age 20 for job 5;
*hrs2005 is the number of hours worked since age 20 for job 5;
*ehrs2005 is the number of employee-type job hours worked since age 20 for job
5;
array hours hours01-hours09;
array self &R9sel;
array wks14 wks1401-wks1409;
array hrs14 hrs1401-hrs1409;
array ehrs14 ehrs1401-ehrs1409;
array wks20 wks2001-wks2009;
array hrs20 hrs2001-hrs2009;
array ehrs20 ehrs2001-ehrs2009;
array jobwks job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wjs
job9wks;
do over wks14;
wks14=0;
hrs14=0;
ehrs14=0;
wks20=0;
hrs20=0;
ehrs20=0;
end;
*********************** the created variable for endwk age 14-19";
end14wk=min(age20wk-1, 1388);
* The number of weeks worked on each job age 14-19;
do over wks14;
do i=age14wk to end14wk;
if jobwks=1 then wks14=wks14+1;
end;
do i=age14wk to end14wk;
if jobwks=-3 then wks14=-3;
end;
end;
* The number of hours worked on each job age 14-19;
do over hours;
if hours ge 0 and wks14 ge 0 then hrs14=hours*wks14;
else if wks14=-3 or (hours in (-1,-2,-3) and wks14 ne 0) then hrs14=-3;
if self=0 then ehrs14=hrs14;
end;
* The total number of hours worked age 14-19;
do over hrs14;
if hrs14 ge 0 then r9hrs14 = r9hrs14 + hrs14;
if ehrs14 ge 0 then r9ehrs14 = r9ehrs14 + ehrs14;
end;
do over hrs14;
if hrs14=-3 then r9hrs14=-3;
if ehrs14=-3 then r9ehrs14=-3;
end;
***************** The created variable for "since age 20";
if age14wk>0 and age20wk<=1388 then do;
* The number of weeks worked since age 20 for the respondents who have turned 20
by round9;
do over wks20;
do i=age20wk to 1388;
if jobwks=1 then wks20=wks20+1;
end;
do i=age20wk to 1388;
if jobwks=-3 then wks20=-3;
end;
end;
end;
* The number of hours worked since age 20 for the respondents who have turned 20
by Round 9;
do over hrs20;
if hours ge 0 and wks20 ge 0 then hrs20=hours*wks20;
else if wks20=-3 or (hours in (-1,-2,-3) and wks20 ne 0) then hrs20=-3;
if self=0 then ehrs20=hrs20;
end;
* The total number of hours worked since age 20;
do over hrs20;
if hrs20 ge 0 then r9hrs20 = r9hrs20 + hrs20;
if ehrs20 ge 0 then r9ehrs20 = r9ehrs20 + ehrs20;
end;
do over hrs20;
if hrs20=-3 then r9hrs20=-3;
if ehrs20=-3 then r9ehrs20=-3;
end;
proc means n mean min max data=emp35_hrsage14;
var idcode r9hrs14 r9ehrs14 r9hrs20 r9ehrs20 dliwk end14wk;
title2 'Emp35_hrsage14';
run;
data emp36_numjobs(keep=idcode r9job80-r9job99 r9job00-r9job06 r9self80-r9self99
r9self00-r9self06
r9emp80-r9emp99 r9emp00-r9emp06);
merge two(keep=idcode &r9sel) emp_bday emp_int emp_countweeks;
by idcode; if r9int ne -5;
/* This program is only used as an in-file for total_numjobs.sas, which combines
the dli Round created
variables for number of jobs in a given year. */
**********************************************************************
** Number of jobs held during 19## (conditional on working at least 1 week
during that year.
**********************************************************************;
array job1wks (i) _1-_730 w1_731-w1_1388;
array job2wks (i) _1-_730 w2_731-w2_1388;
array job3wks (i) _1-_730 w3_731-w3_1388;
array job4wks (i) _1-_730 w4_731-w4_1388;
array job5wks (i) _1-_730 w5_731-w5_1388;
array job6wks (i) _1-_730 w6_731-w6_1388;
array job7wks (i) _1-_730 w7_731-w7_1388;
array job8wks (i) _1-_730 w8_731-w8_1388;
array job9wks (i) _1-_730 w9_731-w9_1388;
*******************************************************************
** Indicate if worked at least one week on a job in a given year **
*******************************************************************;
r9job80 =0; r9self80=0; r9emp80 =0;
r9job81 =0; r9self81=0; r9emp81 =0;
r9job82 =0; r9self82=0; r9emp82 =0;
r9job83 =0; r9self83=0; r9emp83 =0;
r9job84 =0; r9self84=0; r9emp84 =0;
r9job85 =0; r9self85=0; r9emp85 =0;
r9job86 =0; r9self86=0; r9emp86 =0;
r9job87 =0; r9self87=0; r9emp87 =0;
r9job88 =0; r9self88=0; r9emp88 =0;
r9job89 =0; r9self89=0; r9emp89 =0;
r9job90 =0; r9self90=0; r9emp90 =0;
r9job91 =0; r9self91=0; r9emp91 =0;
r9job92 =0; r9self92=0; r9emp92 =0;
r9job93 =0; r9self93=0; r9emp93 =0;
array self &r9sel;
array jobwks job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks
job9wks;
/* 1994 */
array r9j94 r9j9401-r9j9409;
array r9s94 r9s9401-r9s9409;
array r9e94 r9e9401-r9e9409;
do over r9j94; r9j94=0; r9s94=0; r9e94=0; end;
do over r9j94;
do i=731 to 783;
if jobwks=-3 then r9j94=-3;
if jobwks=-3 and self=1 then r9s94=-3;
if jobwks=-3 and self=0 then r9e94=-3;
end;
do i=731 to 783;
if jobwks=1 then r9j94=1;
if jobwks=1 and self=1 then r9s94=1;
if jobwks=1 and self=0 then r9e94=1;
end;
end;
r9job94=sum(r9j9401,r9j9402,r9j9403,r9j9404,r9j9405,r9j9406,r9j9407,r9j9408,r9j9409);
if (r9j9401=-3 or r9j9402=-3 or r9j9403=-3 or r9j9404=-3 or r9j9405=-3 or
r9j9406=-3 or
r9j9407=-3 or r9j9408=-3 or r9j9409=-3) then r9job94=-3;
r9self94=sum(r9s9401,r9s9402,r9s9403,r9s9404,r9s9405,r9s9406,r9s9407,r9s9408,r9s9409);
if (r9s9401=-3 or r9s9402=-3 or r9s9403=-3 or r9s9404=-3 or r9s9405=-3 or
r9s9406=-3 or
r9s9407=-3 or r9s9408=-3 or r9s9409=-3) then r9self94=-3;
r9emp94=sum(r9e9401,r9e9402,r9e9403,r9e9404,r9e9405,r9e9406,r9e9407,r9e9408,r9e9409);
if (r9e9401=-3 or r9e9402=-3 or r9e9403=-3 or r9e9404=-3 or r9e9405=-3 or
r9e9406=-3 or
r9e9407=-3 or r9e9408=-3 or r9e9409=-3) then r9emp94=-3;
/* 1995 */
array r9j95 r9j9501-r9j9509;
array r9s95 r9s9501-r9s9509;
array r9e95 r9e9501-r9e9509;
do over r9j95; r9j95=0; r9s95=0; r9e95=0; end;
do over r9j95;
do i=784 to 835;
if jobwks=-3 then r9j95=-3;
if jobwks=-3 and self=1 then r9s95=-3;
if jobwks=-3 and self=0 then r9e95=-3;
end;
do i=784 to 835;
if jobwks=1 then r9j95=1;
if jobwks=1 and self=1 then r9s95=1;
if jobwks=1 and self=0 then r9e95=1;
end;
end;
r9job95=sum(r9j9501,r9j9502,r9j9503,r9j9504,r9j9505,r9j9506,r9j9507,r9j9508,r9j9509);
if (r9j9501=-3 or r9j9502=-3 or r9j9503=-3 or r9j9504=-3 or r9j9505=-3 or
r9j9506=-3 or
r9j9507=-3 or r9j9508=-3 or r9j9509=-3) then r9job95=-3;
r9self95=sum(r9s9501,r9s9502,r9s9503,r9s9504,r9s9505,r9s9506,r9s9507,r9s9508,r9s9509);
if (r9s9501=-3 or r9s9502=-3 or r9s9503=-3 or r9s9504=-3 or r9s9505=-3 or
r9s9506=-3 or
r9s9507=-3 or r9s9508=-3 or r9s9509=-3) then r9self95=-3;
r9emp95=sum(r9e9501,r9e9502,r9e9503,r9e9504,r9e9505,r9e9506,r9e9507,r9e9508,r9e9509);
if (r9e9501=-3 or r9e9502=-3 or r9e9503=-3 or r9e9504=-3 or r9e9505=-3 or
r9e9506=-3 or
r9e9507=-3 or r9e9508=-3 or r9e9509=-3) then r9emp95=-3;
/* 1996 */
array r9j96 r9j9601-r9j9609;
array r9s96 r9s9601-r9s9609;
array r9e96 r9e9601-r9e9609;
do over r9j96; r9j96=0; r9s96=0; r9e96=0; end;
do over r9j96;
do i=836 to 887;
if jobwks=-3 then r9j96=-3;
if jobwks=-3 and self=1 then r9s96=-3;
if jobwks=-3 and self=0 then r9e96=-3;
end;
do i=836 to 887;
if jobwks=1 then r9j96=1;
if jobwks=1 and self=1 then r9s96=1;
if jobwks=1 and self=0 then r9e96=1;
end;
end;
r9job96=sum(r9j9601,r9j9602,r9j9603,r9j9604,r9j9605,r9j9606,r9j9607,r9j9608,r9j9609);
if (r9j9601=-3 or r9j9602=-3 or r9j9603=-3 or r9j9604=-3 or r9j9605=-3 or
r9j9606=-3 or
r9j9607=-3 or r9j9608=-3 or r9j9609=-3) then r9job96=-3;
r9self96=sum(r9s9601,r9s9602,r9s9603,r9s9604,r9s9605,r9s9606,r9s9607,r9s9608,r9s9609);
if (r9s9601=-3 or r9s9602=-3 or r9s9603=-3 or r9s9604=-3 or r9s9605=-3 or
r9s9606=-3 or
r9s9607=-3 or r9s9608=-3 or r9s9609=-3) then r9self96=-3;
r9emp96=sum(r9e9601,r9e9602,r9e9603,r9e9604,r9e9605,r9e9606,r9e9607,r9e9608,r9e9609);
if (r9e9601=-3 or r9e9602=-3 or r9e9603=-3 or r9e9604=-3 or r9e9605=-3 or
r9e9606=-3 or
r9e9607=-3 or r9e9608=-3 or r9e9609=-3) then r9emp96=-3;
/* 1997 */
array r9j97 r9j9701-r9j9709;
array r9s97 r9s9701-r9s9709;
array r9e97 r9e9701-r9e9709;
do over r9j97; r9j97=0; r9s97=0; r9e97=0; end;
do over r9j97;
do i=888 to 939;
if jobwks=-3 then r9j97=-3;
if jobwks=-3 and self=1 then r9s97=-3;
if jobwks=-3 and self=0 then r9e97=-3;
end;
do i=888 to 939;
if jobwks=1 then r9j97=1;
if jobwks=1 and self=1 then r9s97=1;
if jobwks=1 and self=0 then r9e97=1;
end;
end;
r9job97=sum(r9j9701,r9j9702,r9j9703,r9j9704,r9j9705,r9j9706,r9j9707,r9j9708,r9j9709);
if (r9j9701=-3 or r9j9702=-3 or r9j9703=-3 or r9j9704=-3 or r9j9705=-3 or
r9j9706=-3 or
r9j9707=-3 or r9j9708=-3 or r9j9709=-3) then r9job97=-3;
r9self97=sum(r9s9701,r9s9702,r9s9703,r9s9704,r9s9705,r9s9706,r9s9707,r9s9708,r9s9709);
if (r9s9701=-3 or r9s9702=-3 or r9s9703=-3 or r9s9704=-3 or r9s9705=-3 or
r9s9706=-3 or
r9s9707=-3 or r9s9708=-3 or r9s9709=-3) then r9self97=-3;
r9emp97=sum(r9e9701,r9e9702,r9e9703,r9e9704,r9e9705,r9e9706,r9e9707,r9e9708,r9e9709);
if (r9e9701=-3 or r9e9702=-3 or r9e9703=-3 or r9e9704=-3 or r9e9705=-3 or
r9e9706=-3 or
r9e9707=-3 or r9e9708=-3 or r9e9709=-3) then r9emp97=-3;
/* 1998 */
array r9j98 r9j9801-r9j9809;
array r9s98 r9s9801-r9s9809;
array r9e98 r9e9801-r9e9809;
do over r9j98; r9j98=0; r9s98=0; r9e98=0; end;
do over r9j98;
do i=940 to 991;
if jobwks=-3 then r9j98=-3;
if jobwks=-3 and self=1 then r9s98=-3;
if jobwks=-3 and self=0 then r9e98=-3;
end;
do i=940 to 991;
if jobwks=1 then r9j98=1;
if jobwks=1 and self=1 then r9s98=1;
if jobwks=1 and self=0 then r9e98=1;
end;
end;
r9job98=sum(r9j9801,r9j9802,r9j9803,r9j9804,r9j9805,r9j9806,r9j9807,r9j9808,r9j9809);
if (r9j9801=-3 or r9j9802=-3 or r9j9803=-3 or r9j9804=-3 or r9j9805=-3 or
r9j9806=-3 or
r9j9807=-3 or r9j9808=-3 or r9j9809=-3) then r9job98=-3;
r9self98=sum(r9s9801,r9s9802,r9s9803,r9s9804,r9s9805,r9s9806,r9s9807,r9s9808,r9s9809);
if (r9s9801=-3 or r9s9802=-3 or r9s9803=-3 or r9s9804=-3 or r9s9805=-3 or
r9s9806=-3 or
r9s9807=-3 or r9s9808=-3 or r9s9809=-3) then r9self98=-3;
r9emp98=sum(r9e9801,r9e9802,r9e9803,r9e9804,r9e9805,r9e9806,r9e9807,r9e9808,r9e9809);
if (r9e9801=-3 or r9e9802=-3 or r9e9803=-3 or r9e9804=-3 or r9e9805=-3 or
r9e9806=-3 or
r9e9807=-3 or r9e9808=-3 or r9e9809=-3) then r9emp98=-3;
/* 1999 */
array r9j99 r9j9901-r9j9909;
array r9s99 r9s9901-r9s9909;
array r9e99 r9e9901-r9e9909;
do over r9j99; r9j99=0; r9s99=0; r9e99=0; end;
do over r9j99;
do i=992 to 1043;
if jobwks=-3 then r9j99=-3;
if jobwks=-3 and self=1 then r9s99=-3;
if jobwks=-3 and self=0 then r9e99=-3;
end;
do i=992 to 1043;
if jobwks=1 then r9j99=1;
if jobwks=1 and self=1 then r9s99=1;
if jobwks=1 and self=0 then r9e99=1;
end;
end;
r9job99=sum(r9j9901,r9j9902,r9j9903,r9j9904,r9j9905,r9j9906,r9j9907,r9j9908,r9j9909);
if (r9j9901=-3 or r9j9902=-3 or r9j9903=-3 or r9j9904=-3 or r9j9905=-3 or
r9j9906=-3 or
r9j9907=-3 or r9j9908=-3 or r9j9909=-3) then r9job99=-3;
r9self99=sum(r9s9901,r9s9902,r9s9903,r9s9904,r9s9905,r9s9906,r9s9907,r9s9908,r9s9909);
if (r9s9901=-3 or r9s9902=-3 or r9s9903=-3 or r9s9904=-3 or r9s9905=-3 or
r9s9906=-3 or
r9s9907=-3 or r9s9908=-3 or r9s9909=-3) then r9self99=-3;
r9emp99=sum(r9e9901,r9e9902,r9e9903,r9e9904,r9e9905,r9e9906,r9e9907,r9e9908,r9e9909);
if (r9e9901=-3 or r9e9902=-3 or r9e9903=-3 or r9e9904=-3 or r9e9905=-3 or
r9e9906=-3 or
r9e9907=-3 or r9e9908=-3 or r9e9909=-3) then r9emp99=-3;
/* 2000 */
array r9j00 r9j0001-r9j0009;
array r9s00 r9s0001-r9s0009;
array r9e00 r9e0001-r9e0009;
do over r9j00; r9j00=0; r9s00=0; r9e00=0; end;
do over r9j00;
do i=1044 to 1096;
if jobwks=-3 then r9j00=-3;
if jobwks=-3 and self=1 then r9s00=-3;
if jobwks=-3 and self=0 then r9e00=-3;
end;
do i=1044 to 1096;
if jobwks=1 then r9j00=1;
if jobwks=1 and self=1 then r9s00=1;
if jobwks=1 and self=0 then r9e00=1;
end;
end;
r9job00=sum(r9j0001,r9j0002,r9j0003,r9j0004,r9j0005,r9j0006,r9j0007,r9j0008,r9j0009);
if (r9j0001=-3 or r9j0002=-3 or r9j0003=-3 or r9j0004=-3 or r9j0005=-3 or
r9j0006=-3 or
r9j0007=-3 or r9j0008=-3 or r9j0009=-3) then r9job00=-3;
r9self00=sum(r9s0001,r9s0002,r9s0003,r9s0004,r9s0005,r9s0006,r9s0007,r9s0008,r9s0009);
if (r9s0001=-3 or r9s0002=-3 or r9s0003=-3 or r9s0004=-3 or r9s0005=-3 or
r9s0006=-3 or
r9s0007=-3 or r9s0008=-3 or r9s0009=-3) then r9self00=-3;
r9emp00=sum(r9e0001,r9e0002,r9e0003,r9e0004,r9e0005,r9e0006,r9e0007,r9e0008,r9e0009);
if (r9e0001=-3 or r9e0002=-3 or r9e0003=-3 or r9e0004=-3 or r9e0005=-3 or
r9e0006=-3 or
r9e0007=-3 or r9e0008=-3 or r9e0009=-3) then r9emp00=-3;
/* 2001 */
array r9j01 r9j0101-r9j0109;
array r9s01 r9s0101-r9s0109;
array r9e01 r9e0101-r9e0109;
do over r9j01; r9j01=0; r9s01=0; r9e01=0; end;
do over r9j01;
do i=1097 to 1148;
if jobwks=-3 then r9j01=-3;
if jobwks=-3 and self=1 then r9s01=-3;
if jobwks=-3 and self=0 then r9e01=-3;
end;
do i=1097 to 1148;
if jobwks=1 then r9j01=1;
if jobwks=1 and self=1 then r9s01=1;
if jobwks=1 and self=0 then r9e01=1;
end;
end;
r9job01=sum(r9j0101,r9j0102,r9j0103,r9j0104,r9j0105,r9j0106,r9j0107,r9j0108,r9j0109);
if (r9j0101=-3 or r9j0102=-3 or r9j0103=-3 or r9j0104=-3 or r9j0105=-3 or
r9j0106=-3 or
r9j0107=-3 or r9j0108=-3 or r9j0109=-3) then r9job01=-3;
r9self01=sum(r9s0101,r9s0102,r9s0103,r9s0104,r9s0105,r9s0106,r9s0107,r9s0108,r9s0109);
if (r9s0101=-3 or r9s0102=-3 or r9s0103=-3 or r9s0104=-3 or r9s0105=-3 or
r9s0106=-3 or
r9s0107=-3 or r9s0108=-3 or r9s0109=-3) then r9self01=-3;
r9emp01=sum(r9e0101,r9e0102,r9e0103,r9e0104,r9e0105,r9e0106,r9e0107,r9e0108,r9e0109);
if (r9e0101=-3 or r9e0102=-3 or r9e0103=-3 or r9e0104=-3 or r9e0105=-3 or
r9e0106=-3 or
r9e0107=-3 or r9e0108=-3 or r9e0109=-3) then r9emp01=-3;
/* 2002 */
array r9j02 r9j0201-r9j0209;
array r9s02 r9s0201-r9s0209;
array r9e02 r9e0201-r9e0209;
do over r9j02; r9j02=0; r9s02=0; r9e02=0; end;
do over r9j02;
do i=1149 to 1200;
if jobwks=-3 then r9j02=-3;
if jobwks=-3 and self=1 then r9s02=-3;
if jobwks=-3 and self=0 then r9e02=-3;
end;
do i=1149 to 1200;
if jobwks=1 then r9j02=1;
if jobwks=1 and self=1 then r9s02=1;
if jobwks=1 and self=0 then r9e02=1;
end;
end;
r9job02=sum(r9j0201,r9j0202,r9j0203,r9j0204,r9j0205,r9j0206,r9j0207,r9j0208,r9j0209);
if (r9j0201=-3 or r9j0202=-3 or r9j0203=-3 or r9j0204=-3 or r9j0205=-3 or
r9j0206=-3 or
r9j0207=-3 or r9j0208=-3 or r9j0209=-3) then r9job02=-3;
r9self02=sum(r9s0201,r9s0202,r9s0203,r9s0204,r9s0205,r9s0206,r9s0207,r9s0208,r9s0209);
if (r9s0201=-3 or r9s0202=-3 or r9s0203=-3 or r9s0204=-3 or r9s0205=-3 or
r9s0206=-3 or
r9s0207=-3 or r9s0208=-3 or r9s0209=-3) then r9self02=-3;
r9emp02=sum(r9e0201,r9e0202,r9e0203,r9e0204,r9e0205,r9e0206,r9e0207,r9e0208,r9e0209);
if (r9e0201=-3 or r9e0202=-3 or r9e0203=-3 or r9e0204=-3 or r9e0205=-3 or
r9e0206=-3 or
r9e0207=-3 or r9e0208=-3 or r9e0209=-3) then r9emp02=-3;
/* 2003 */
array r9j03 r9j0301-r9j0309;
array r9s03 r9s0301-r9s0309;
array r9e03 r9e0301-r9e0309;
do over r9j03; r9j03=0; r9s03=0; r9e03=0; end;
do over r9j03;
do i=1201 to 1252;
if jobwks=-3 then r9j03=-3;
if jobwks=-3 and self=1 then r9s03=-3;
if jobwks=-3 and self=0 then r9e03=-3;
end;
do i=1201 to 1252;
if jobwks=1 then r9j03=1;
if jobwks=1 and self=1 then r9s03=1;
if jobwks=1 and self=0 then r9e03=1;
end;
end;
r9job03=sum(r9j0301,r9j0302,r9j0303,r9j0304,r9j0305,r9j0306,r9j0307,r9j0308,r9j0309);
if (r9j0301=-3 or r9j0302=-3 or r9j0303=-3 or r9j0304=-3 or r9j0305=-3 or
r9j0306=-3 or
r9j0307=-3 or r9j0308=-3 or r9j0309=-3) then r9job03=-3;
r9self03=sum(r9s0301,r9s0302,r9s0303,r9s0304,r9s0305,r9s0306,r9s0307,r9s0308,r9s0309);
if (r9s0301=-3 or r9s0302=-3 or r9s0303=-3 or r9s0304=-3 or r9s0305=-3 or
r9s0306=-3 or
r9s0307=-3 or r9s0308=-3 or r9s0309=-3) then r9self03=-3;
r9emp03=sum(r9e0301,r9e0302,r9e0303,r9e0304,r9e0305,r9e0306,r9e0307,r9e0308,r9e0309);
if (r9e0301=-3 or r9e0302=-3 or r9e0303=-3 or r9e0304=-3 or r9e0305=-3 or
r9e0306=-3 or
r9e0307=-3 or r9e0308=-3 or r9e0309=-3) then r9emp03=-3;
/* 2004 */
array r9j04 r9j0401-r9j0409;
array r9s04 r9s0401-r9s0409;
array r9e04 r9e0401-r9e0409;
do over r9j04; r9j04=0; r9s04=0; r9e04=0; end;
do over r9j04;
do i=1253 to 1304;
if jobwks=-3 then r9j04=-3;
if jobwks=-3 and self=1 then r9s04=-3;
if jobwks=-3 and self=0 then r9e04=-3;
end;
do i=1253 to 1304;
if jobwks=1 then r9j04=1;
if jobwks=1 and self=1 then r9s04=1;
if jobwks=1 and self=0 then r9e04=1;
end;
end;
r9job04=sum(r9j0401,r9j0402,r9j0403,r9j0404,r9j0405,r9j0406,r9j0407,r9j0408,r9j0409);
if (r9j0401=-3 or r9j0402=-3 or r9j0403=-3 or r9j0404=-3 or r9j0405=-3 or
r9j0406=-3 or
r9j0407=-3 or r9j0408=-3 or r9j0409=-3) then r9job04=-3;
r9self04=sum(r9s0401,r9s0402,r9s0403,r9s0404,r9s0405,r9s0406,r9s0407,r9s0408,r9s0409);
if (r9s0401=-3 or r9s0402=-3 or r9s0403=-3 or r9s0404=-3 or r9s0405=-3 or
r9s0406=-3 or
r9s0407=-3 or r9s0408=-3 or r9s0409=-3) then r9self04=-3;
r9emp04=sum(r9e0401,r9e0402,r9e0403,r9e0404,r9e0405,r9e0406,r9e0407,r9e0408,r9e0409);
if (r9e0401=-3 or r9e0402=-3 or r9e0403=-3 or r9e0404=-3 or r9e0405=-3 or
r9e0406=-3 or
r9e0407=-3 or r9e0408=-3 or r9e0409=-3) then r9emp04=-3;
/* 2005 */
array r9j05 r9j0501-r9j0509;
array r9s05 r9s0501-r9s0509;
array r9e05 r9e0501-r9e0509;
do over r9j05; r9j05=0; r9s05=0; r9e05=0; end;
do over r9j05;
do i=1305 to 1357;
if jobwks=-3 then r9j05=-3;
if jobwks=-3 and self=1 then r9s05=-3;
if jobwks=-3 and self=0 then r9e05=-3;
end;
do i=1305 to 1357;
if jobwks=1 then r9j05=1;
if jobwks=1 and self=1 then r9s05=1;
if jobwks=1 and self=0 then r9e05=1;
end;
end;
r9job05=sum(r9j0501,r9j0502,r9j0503,r9j0504,r9j0505,r9j0506,r9j0507,r9j0508,r9j0509);
if (r9j0501=-3 or r9j0502=-3 or r9j0503=-3 or r9j0504=-3 or r9j0505=-3 or
r9j0506=-3 or
r9j0507=-3 or r9j0508=-3 or r9j0509=-3) then r9job05=-3;
r9self05=sum(r9s0501,r9s0502,r9s0503,r9s0504,r9s0505,r9s0506,r9s0507,r9s0508,r9s0509);
if (r9s0501=-3 or r9s0502=-3 or r9s0503=-3 or r9s0504=-3 or r9s0505=-3 or
r9s0506=-3 or
r9s0507=-3 or r9s0508=-3 or r9s0509=-3) then r9self05=-3;
r9emp05=sum(r9e0501,r9e0502,r9e0503,r9e0504,r9e0505,r9e0506,r9e0507,r9e0508,r9e0509);
if (r9e0501=-3 or r9e0502=-3 or r9e0503=-3 or r9e0504=-3 or r9e0505=-3 or
r9e0506=-3 or
r9e0507=-3 or r9e0508=-3 or r9e0509=-3) then r9emp05=-3;
/* 2006 */
array r9j06 r9j0601-r9j0609;
array r9s06 r9s0601-r9s0609;
array r9e06 r9e0601-r9e0609;
do over r9j06; r9j06=0; r9s06=0; r9e06=0; end;
do over r9j06;
do i=1358 to 1388;
if jobwks=-3 then r9j06=-3;
if jobwks=-3 and self=1 then r9s06=-3;
if jobwks=-3 and self=0 then r9e06=-3;
end;
do i=1358 to 1388;
if jobwks=1 then r9j06=1;
if jobwks=1 and self=1 then r9s06=1;
if jobwks=1 and self=0 then r9e06=1;
end;
end;
r9job06=sum(r9j0601,r9j0602,r9j0603,r9j0604,r9j0605,r9j0606,r9j0607,r9j0608,r9j0609);
if (r9j0601=-3 or r9j0602=-3 or r9j0603=-3 or r9j0604=-3 or r9j0605=-3 or
r9j0606=-3 or
r9j0607=-3 or r9j0608=-3 or r9j0609=-3) then r9job06=-3;
r9self06=sum(r9s0601,r9s0602,r9s0603,r9s0604,r9s0605,r9s0606,r9s0607,r9s0608,r9s0609);
if (r9s0601=-3 or r9s0602=-3 or r9s0603=-3 or r9s0604=-3 or r9s0605=-3 or
r9s0606=-3 or
r9s0607=-3 or r9s0608=-3 or r9s0609=-3) then r9self06=-3;
r9emp06=sum(r9e0601,r9e0602,r9e0603,r9e0604,r9e0605,r9e0606,r9e0607,r9e0608,r9e0609);
if (r9e0601=-3 or r9e0602=-3 or r9e0603=-3 or r9e0604=-3 or r9e0605=-3 or
r9e0606=-3 or
r9e0607=-3 or r9e0608=-3 or r9e0609=-3) then r9emp06=-3;
proc means n mean min max;
title2 'Emp36_numjobs';
var idcode r9job80-r9job99 r9job00-r9job06
r9self80-r9self99 r9self00-r9self06 r9emp80-r9emp99 r9emp00-r9emp06;
run;
data emp37_numjobs14(keep=idcode r9emp14 r9job14 r9job20 r9emp20
r9e1401-r9e1409 r9j1401-r9j1409 r9e2001-r9e2009 r9j2001-r9j2009
end14wk);
merge two emp_bday emp_int emp_week emp_countweeks; by idcode;
if r9int ne -5;
**********************************************************************
** Number of jobs held since age 14 & since age 20
** **
** Variables created: r9emp14 r9job14 r9emp20 r9job20
** **
** r9job14 (r9emp14) is the number of all jobs (employee type jobs) held between
14 & 20
** r9job20 (r9emp20) is the number of all jobs (employee type jobs) held since
age 20
**********************************************************************;
array job1wks (i) _1-_730 w1_731-w1_1388;
array job2wks (i) _1-_730 w2_731-w2_1388;
array job3wks (i) _1-_730 w3_731-w3_1388;
array job4wks (i) _1-_730 w4_731-w4_1388;
array job5wks (i) _1-_730 w5_731-w5_1388;
array job6wks (i) _1-_730 w6_731-w6_1388;
array job7wks (i) _1-_730 w7_731-w7_1388;
array job8wks (i) _1-_730 w8_731-w8_1388;
array job9wks (i) _1-_730 w9_731-w9_1388;
***************************************************************************
** Indicate if worked at least one week on a given job since age 14 & 20 **
***************************************************************************;
array r9e14 r9e1401-r9e1409;
array r9j14 r9j1401-r9j1409;
array r9e20 r9e2001-r9e2009;
array r9j20 r9j2001-r9j2009;
array self &R9sel;
array jobwks job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks
job9wks;
* the ending week for the count "between age 14 and 20" depending on whether the
respondent turns to 20 or not;
end14wk=min(age20wk-1, 1388);
* the count for "between age 14 and 20"--all jobs;
do over r9j14;
do i=age14wk to end14wk;
if jobwks in (-3,1) then r9j14=1;
* the count for "between age 14 and 20"--employee type jobs;
if jobwks in (-3,1) and self=0 then r9e14=1;
* the count for "since age 20" for those who are over 20 at interview date--all
jobs;
end;
do i=age20wk to 1388;
if jobwks in (-3,1) then r9j20=1;
* the count for "since age 20" for those who are over 20 at interview
date--employee type jobs;
if jobwks in (-3,1) and self=0 then r9e20=1;
end;
end;
r9job14=sum(r9j1401,r9j1402,r9j1403,r9j1404,r9j1405,r9j1406,r9j1407,r9j1408,r9j1409);
r9emp14=sum(r9e1401,r9e1402,r9e1403,r9e1404,r9e1405,r9e1406,r9e1407,r9e1408,r9e1409);
r9job20=sum(r9j2001,r9j2002,r9j2003,r9j2004,r9j2005,r9j2006,r9j2007,r9j2008,r9j2009);
r9emp20=sum(r9e2001,r9e2002,r9e2003,r9e2004,r9e2005,r9e2006,r9e2007,r9e2008,r9e2009);
******** assign -3 to cases where the stop date is unknown
and the job starts prior to the 14/20th birthday; *******;
array starw starw01-starw09;
array stopf stopf_1-stopf_9;
array starf starf_1-starf_9;
do over stopf;
if stopf=1 and starf ne 1 and starw<age14wk and self=0 then r9emp14=-3;
if stopf=1 and starf ne 1 and starw<age14wk then r9emp14=-3;
if stopf=1 and starf ne 1 and starw<age20wk and self=0 and age20wk<r9int then
r9emp20=-3;
if stopf=1 and starf ne 1 and starw<age20wk and age20wk<r9int then r9job20=-3;
end;