/* This program creates the CV_MAINJOB_FLG variable, which identifies the main job using CPS definitions*/ /**********************************************************************; QNAME Variable Names CV_HRS_PER_WEEK.01_2021 HRS01 CV_HRS_PER_WEEK.02_2021 HRS02 CV_HRS_PER_WEEK.03_2021 HRS03 CV_HRS_PER_WEEK.04_2021 HRS04 CV_HRS_PER_WEEK.05_2021 HRS05 CV_HRS_PER_WEEK.06_2021 HRS06 CV_HRS_PER_WEEK.07_2021 HRS07 CV_HRS_PER_WEEK.08_2021 HRS08 CV_HRS_PER_WEEK.09_2021 HRS09 CV_HRS_PER_WEEK.10_2021 HRS10 YEMP_CURFLAG.01_2021 CUR01 YEMP_CURFLAG.02_2021 CUR02 YEMP_CURFLAG.03_2021 CUR03 YEMP_CURFLAG.04_2021 CUR04 YEMP_CURFLAG.05_2021 CUR05 YEMP_CURFLAG.06_2021 CUR06 YEMP_CURFLAG.07_2021 CUR07 YEMP_CURFLAG.08_2021 CUR08 YEMP_CURFLAG.09_2021 CUR09 YEMP_CURFLAG.10_2021 CUR10 YEMP_STOPDATE.01~D_2021 EnD01 YEMP_STOPDATE.01~M_2021 EnM01 YEMP_STOPDATE.01~Y_2021 EnY01 YEMP_STOPDATE.02~D_2021 EnD02 YEMP_STOPDATE.02~M_2021 EnM02 YEMP_STOPDATE.02~Y_2021 EnY02 YEMP_STOPDATE.03~D_2021 EnD03 YEMP_STOPDATE.03~M_2021 EnM03 YEMP_STOPDATE.03~Y_2021 EnY03 YEMP_STOPDATE.04~D_2021 EnD04 YEMP_STOPDATE.04~M_2021 EnM04 YEMP_STOPDATE.04~Y_2021 EnY04 YEMP_STOPDATE.05~D_2021 EnD05 YEMP_STOPDATE.05~M_2021 EnM05 YEMP_STOPDATE.05~Y_2021 EnY05 YEMP_STOPDATE.06~D_2021 EnD06 YEMP_STOPDATE.06~M_2021 EnM06 YEMP_STOPDATE.06~Y_2021 EnY06 YEMP_STOPDATE.07~D_2021 EnD07 YEMP_STOPDATE.07~M_2021 EnM07 YEMP_STOPDATE.07~Y_2021 EnY07 YEMP_STOPDATE.08~D_2021 EnD08 YEMP_STOPDATE.08~M_2021 EnM08 YEMP_STOPDATE.08~Y_2021 EnY08 YEMP_STOPDATE.09~D_2021 EnD09 YEMP_STOPDATE.09~M_2021 EnM09 YEMP_STOPDATE.09~Y_2021 EnY09 YEMP_STOPDATE.10~D_2021 EnD10 YEMP_STOPDATE.10~M_2021 EnM10 YEMP_STOPDATE.10~Y_2021 EnY10 YEMP_STARTDATE.01~D_2021 STD01 YEMP_STARTDATE.01~M_2021 STM01 YEMP_STARTDATE.01~Y_2021 STY01 YEMP_STARTDATE.02~D_2021 STD02 YEMP_STARTDATE.02~M_2021 STM02 YEMP_STARTDATE.02~Y_2021 STY02 YEMP_STARTDATE.03~D_2021 STD03 YEMP_STARTDATE.03~M_2021 STM03 YEMP_STARTDATE.03~Y_2021 STY03 YEMP_STARTDATE.04~D_2021 STD04 YEMP_STARTDATE.04~M_2021 STM04 YEMP_STARTDATE.04~Y_2021 STY04 YEMP_STARTDATE.05~D_2021 STD05 YEMP_STARTDATE.05~M_2021 STM05 YEMP_STARTDATE.05~Y_2021 STY05 YEMP_STARTDATE.06~D_2021 STD06 YEMP_STARTDATE.06~M_2021 STM06 YEMP_STARTDATE.06~Y_2021 STY06 YEMP_STARTDATE.07~D_2021 STD07 YEMP_STARTDATE.07~M_2021 STM07 YEMP_STARTDATE.07~Y_2021 STY07 YEMP_STARTDATE.08~D_2021 STD08 YEMP_STARTDATE.08~M_2021 STM08 YEMP_STARTDATE.08~Y_2021 STY08 YEMP_STARTDATE.09~D_2021 STD09 YEMP_STARTDATE.09~M_2021 STM09 YEMP_STARTDATE.09~Y_2021 STY09 YEMP_STARTDATE.10~D_2021 STD10 YEMP_STARTDATE.10~M_2021 STM10 YEMP_STARTDATE.10~Y_2021 STY10 YEMP_UID.01_2021 UID01 YEMP_UID.02_2021 UID02 YEMP_UID.03_2021 UID03 YEMP_UID.04_2021 UID04 YEMP_UID.05_2021 UID05 YEMP_UID.06_2021 UID06 YEMP_UID.07_2021 UID07 YEMP_UID.08_2021 UID08 YEMP_UID.09_2021 UID09 YEMP_UID.10_2021 UID10 YEMP_MILFLAG.01_2021 MIL01 YEMP_MILFLAG.02_2021 MIL02 YEMP_MILFLAG.03_2021 MIL03 YEMP_MILFLAG.04_2021 MIL04 YEMP_MILFLAG.05_2021 MIL05 YEMP_MILFLAG.06_2021 MIL06 YEMP_MILFLAG.07_2021 MIL07 YEMP_MILFLAG.08_2021 MIL08 YEMP_MILFLAG.09_2021 MIL09 YEMP_MILFLAG.10_2021 MIL10 ******************************************************************************************************/ /*When more than one current job is reported, the CPS/main job is defined as the job at which the person usually works the most hours. If the person works the same number of hours on more than one current job, then the CPS/main job is the one at which the person has been employed the longest (this does not take account of absences from the job. To calculate this, array the job uids, the current status, the number of hours worked, and the start dates.*/ /*array job identifiers (UID) by round*/ array UID [10] UID01-UID10; /*array current status (CUR) by round*/ array CUR [10] CUR01-CUR10; /*array hours (HRS) by round*/ array HRS [10] HRS01-HRS10; *array military (MIL) by round; array MIL [10] MIL01-MIL10; /*array start day (STDAY) by round*/ array STDAY [10] STD01-STD10; /*array start month (STM) by round*/ array STM [10] STM01-STM10; /*array start year (STY) by round*/ array STY [10] STY01-STY10; /*array start date (BDTE) by round*/ array BDTE [10] BDTE01-BDTE10; /*set any missing start days to the first day of the month*/ do i=1 to 10; if stday(i)<=0 and stday(i)>-4 then stday(i)=1; end; /*calculate the combined start date for all dates with valid day, month year - for all others, set the variable to an invalid skip (-3)*/ do i=1 to 10; if stm(i)>0 and sty(i)>0 then do; BDTE(i)=mdy(stm(i), stday(i), sty(i)); end; else if stm(i) in (-1, -2, -3) or sty(i) in (-1, -2, -3) then do; BDTE(i)=-3; begflg=1; end; end; /*array end day (END) by round*/ array END [10] END01-END10; /*array end month (ENM) by round*/ array ENM [10] ENM01-ENM10; /*array end year (ENY) by round*/ array ENY [10] ENY01-ENY10; *array end date (EDTE) by round; array EDTE [10] EDTE01-EDTE10; do i=1 to 10; if end(i)<0 and end(i)>-4 then end(i)=28; end; /*badstop and badstart should never happen*/ do i=1 to 10; if end(i)=-4 and (enm(i) ne -4 or eny(i) ne -4) then badstop=1; if enm(i)=-4 and (end(i) ne -4 or eny(i) ne -4) then badstop=2; if eny(i)=-4 and (enm(i) ne -4 or end(i) ne -4) then badstop=3; end; do i=1 to 10; if stday(i)=-4 and (stm(i) ne -4 or sty(i) ne -4) then badstart=1; if stm(i)=-4 and (stday(i) ne -4 or sty(i) ne -4) then badstart=2; if sty(i)=-4 and (stm(i) ne -4 or stday(i) ne -4) then badstart=3; end; /*fill in the end-job-months where the corresponding reported year is less than reported year in a job with a good date*/ do i=2 to 10; if enm(i)>-4 and enm(i)<0 and eny(i)>0 and eny(i)0 and eny(i)>0 then do; EDTE(i)=mdy(ENM(i), END(i), ENY(i)); end; else if enm(i) in (-1, -2, -3) or eny(i) in (-1, -2, -3) then do; edte(i)=-3; dteflg=1; end; end; /*determine the main job*/ /*first determine whether the respondent is interviewed in the round and held any civilian job - if not set the variable to -4 (or -5 if not interviewed)*/ if stm01=-5 then cps20=-5; if stm01=-4 and stm02=-4 and stm03=-4 and stm04=-4 and stm05=-4 and stm06=-4 and stm07=-4 and stm08=-4 and stm09=-4 and stm10=-4 then do; cps20=-4; loc=1; end; /*define military jobs and set to missing associated values*/ do i=1 to 10; if MIL(i)=1 then do; EDTE(i)=.; HRS(i)=.; UID(i)=.; CUR(i)=.; end; end; /*count the total number of civilian jobs*/ uidcnt=0; do i=1 to 10; if uid(i)>0 then uidcnt=uidcnt+1; end; do i=1 to 10; *if uidcnt=1 and uid(i)>0 and edte(i)=-3 then cps=i; if uidcnt=1 and uid(i)>0 then do; cps20=i; loc=2; end; end; do i=1 to 10; if cps20=. and edte(i) ne . and edte(i) ne -3 then dtemax=max(edte01, edte02, edte03, edte04, edte05, edte06, edte07, edte08, edte09, edte10); end; /*this is taking out the people with bad end months and years - need to figure it out next*/ do i=1 to 10; *if edte(i)=-3 then dtemax=.; if cps20=. and edte(i)=-3 then dtemax=-3; end; count=0; do i=1 to 10; *if dtemax ne . and dtemax=edte(i) then count=count+1; if dtemax>-3 and dtemax=edte(i) then count=count+1; end; do i=1 to 10; *if cps10=. and count=1 and dtemax ne . and dtemax=edte(i) and dtemax ne . then cps10=i; if cps20=. and count=1 and dtemax>-3 and dtemax=edte(i) then do; cps20=i; loc=3; end; end; if cps20=. and dtemax=. and mil01=1 and mil02 ne 0 and mil03 ne 0 and mil04 ne 0 and mil05 ne 0 and mil06 ne 0 and mil07 ne 0 and mil08 ne 0 and mil09 ne 0 and mil10 ne 0 then do; cps20=-4; loc=4; end; /*check the count of current jobs against the total jobs - if only 1 current job, then choose that for the main job*/ curcnt=0; do i=1 to 10; if cps20=. and cur(i)=1 then curcnt=curcnt+1; end; do i=1 to 10; if cps20=. and curcnt=1 and cur(i)=1 then do; cps20=i; curflg=1; loc=5; end; end; /*for multiple jobs, determine the job with more hours if the dates are the same*/ /*first set to missing any hours for jobs no longer considered*/ do i=1 to 10; if cps20=. and dtemax>-3 and edte(i)>0 and dtemax ne edte(i) then do; hrs(i)=.; bdte(i)=.; end; end; do i=1 to 10; if cps20=. and dtemax>-3 and hrs(i)=-3 then do; cps20=-3; loc=6; end; end; do i=1 to 10; if cps20=. and hrs(i)>-1 and edte(i) ne -3 then hrselg=1; end; do i=1 to 10; if hrselg=1 and hrs(i)>-1 then hrsmax=max(hrs01,hrs02,hrs03,hrs04,hrs05,hrs06,hrs07,hrs08,hrs09,hrs10); end; hrscnt=0; do i=1 to 10; if hrsmax ne . and hrsmax=hrs(i) then hrscnt=hrscnt+1; end; do i=1 to 10; if cps20=. and hrscnt=1 and hrsmax=hrs(i) and hrsmax ne . then do; cps20=i; loc=7; end; end; /*for multiple jobs, determine the job with the earlier start date if hours and end dates are the same*/ do i=1 to 10; if cps20=. and hrsmax ne . and hrselg=1 and hrsmax ne hrs(i) then bdte(i)=.; end; do i=1 to 10; if cps20=. and hrselg=1 and bdte(i)>0 and hrsmax=hrs(i) then dtemin=min(bdte01, bdte02, bdte03, bdte04, bdte05, bdte06, bdte07, bdte08, bdte09, bdte10); end; /*this is taking out the people with bad beginning months and years - need to figure it out next*/ do i=1 to 10; if cps20=. and hrselg=1 and hrsmax=hrs(i) and bdte(i)=-3 then dtemin=-3; end; begcnt=0; do i=1 to 10; if dtemin>-3 and dtemin=bdte(i) then begcnt=begcnt+1; end; do i=1 to 10; if cps20=. and begcnt=1 and dtemin>-3 and dtemin=bdte(i) then do; cps20=i; loc=8; end; end; /*if more than one job has the same end date, hours, and beginning date, then just choose the first on the roster*/ do i=1 to 10; if cps20=. and dtemin ne bdte(i) and dtemin>-3 then bdte(i)=.; end; do i=1 to 10; if cps20=. and dtemin=bdte(i) and dtemin>-3 then do; cps20=i; loc=9; end; end; /*assign invalid skips to respondents without valid job information*/ if cps20=. then do; cps20=-3; loc=10; end; ***** the following to find how many 0 hours are involved; do i=1 to 10; if hrs(i)=0 then hrs0_f1=1; end; do i=1 to 10; if hrs(i)=0 & cps20=i then hrs0_f2=1; end; data mainjob.R20_mainjob; set two; keep pubid cps20; rename cps20=CV_MAINJOB_FLG;