*This program is to create CV_MAINJOB_FLG variable; cps21=CV_MAINJOB_FLG *Variables required: CV_HRS_PER_WEEK.01_2023 = HRS01 CV_HRS_PER_WEEK.02_2023 = HRS02 CV_HRS_PER_WEEK.03_2023 = HRS03 CV_HRS_PER_WEEK.04_2023 = HRS04 CV_HRS_PER_WEEK.05_2023 = HRS05 CV_HRS_PER_WEEK.06_2023 = HRS06 CV_HRS_PER_WEEK.07_2023 = HRS07 CV_HRS_PER_WEEK.08_2023 = HRS08 CV_HRS_PER_WEEK.09_2023 = HRS09 CV_HRS_PER_WEEK.10_2023 = HRS10 YEMP_CURFLAG.01_2023 = CUR01 YEMP_CURFLAG.02_2023 = CUR02 YEMP_CURFLAG.03_2023 = CUR03 YEMP_CURFLAG.04_2023 = CUR04 YEMP_CURFLAG.05_2023 = CUR05 YEMP_CURFLAG.06_2023 = CUR06 YEMP_CURFLAG.07_2023 = CUR07 YEMP_CURFLAG.08_2023 = CUR08 YEMP_CURFLAG.09_2023 = CUR09 YEMP_CURFLAG.10_2023 = CUR10 YEMP_STOPDATE.01~D_2023 = EnD01 YEMP_STOPDATE.01~M_2023 = EnM01 YEMP_STOPDATE.01~Y_2023 = EnY01 YEMP_STOPDATE.02~D_2023 = EnD02 YEMP_STOPDATE.02~M_2023 = EnM02 YEMP_STOPDATE.02~Y_2023 = EnY02 YEMP_STOPDATE.03~D_2023 = EnD03 YEMP_STOPDATE.03~M_2023 = EnM03 YEMP_STOPDATE.03~Y_2023 = EnY03 YEMP_STOPDATE.04~D_2023 = EnD04 YEMP_STOPDATE.04~M_2023 = EnM04 YEMP_STOPDATE.04~Y_2023 = EnY04 YEMP_STOPDATE.05~D_2023 = EnD05 YEMP_STOPDATE.05~M_2023 = EnM05 YEMP_STOPDATE.05~Y_2023 = EnY05 YEMP_STOPDATE.06~D_2023 = EnD06 YEMP_STOPDATE.06~M_2023 = EnM06 YEMP_STOPDATE.06~Y_2023 = EnY06 YEMP_STOPDATE.07~D_2023 = EnD07 YEMP_STOPDATE.07~M_2023 = EnM07 YEMP_STOPDATE.07~Y_2023 = EnY07 YEMP_STOPDATE.08~D_2023 = EnD08 YEMP_STOPDATE.08~M_2023 = EnM08 YEMP_STOPDATE.08~Y_2023 = EnY08 YEMP_STOPDATE.09~D_2023 = EnD09 YEMP_STOPDATE.09~M_2023 = EnM09 YEMP_STOPDATE.09~Y_2023 = EnY09 YEMP_STOPDATE.10~D_2023 = EnD10 YEMP_STOPDATE.10~M_2023 = EnM10 YEMP_STOPDATE.10~Y_2023 = EnY10 YEMP_STARTDATE.01~D_2023 = STD01 YEMP_STARTDATE.01~M_2023 = STM01 YEMP_STARTDATE.01~Y_2023 = STY01 YEMP_STARTDATE.02~D_2023 = STD02 YEMP_STARTDATE.02~M_2023 = STM02 YEMP_STARTDATE.02~Y_2023 = STY02 YEMP_STARTDATE.03~D_2023 = STD03 YEMP_STARTDATE.03~M_2023 = STM03 YEMP_STARTDATE.03~Y_2023 = STY03 YEMP_STARTDATE.04~D_2023 = STD04 YEMP_STARTDATE.04~M_2023 = STM04 YEMP_STARTDATE.04~Y_2023 = STY04 YEMP_STARTDATE.05~D_2023 = STD05 YEMP_STARTDATE.05~M_2023 = STM05 YEMP_STARTDATE.05~Y_2023 = STY05 YEMP_STARTDATE.06~D_2023 = STD06 YEMP_STARTDATE.06~M_2023 = STM06 YEMP_STARTDATE.06~Y_2023 = STY06 YEMP_STARTDATE.07~D_2023 = STD07 YEMP_STARTDATE.07~M_2023 = STM07 YEMP_STARTDATE.07~Y_2023 = STY07 YEMP_STARTDATE.08~D_2023 = STD08 YEMP_STARTDATE.08~M_2023 = STM08 YEMP_STARTDATE.08~Y_2023 = STY08 YEMP_STARTDATE.09~D_2023 = STD09 YEMP_STARTDATE.09~M_2023 = STM09 YEMP_STARTDATE.09~Y_2023 = STY09 YEMP_STARTDATE.10~D_2023 = STD10 YEMP_STARTDATE.10~M_2023 = STM10 YEMP_STARTDATE.10~Y_2023 = STY10 YEMP_UID.01_2023 = UID01 YEMP_UID.02_2023 = UID02 YEMP_UID.03_2023 = UID03 YEMP_UID.04_2023 = UID04 YEMP_UID.05_2023 = UID05 YEMP_UID.06_2023 = UID06 YEMP_UID.07_2023 = UID07 YEMP_UID.08_2023 = UID08 YEMP_UID.09_2023 = UID09 YEMP_UID.10_2023 = UID10 YEMP_MILFLAG.01_2023 = MIL01 YEMP_MILFLAG.02_2023 = MIL02 YEMP_MILFLAG.03_2023 = MIL03 YEMP_MILFLAG.04_2023 = MIL04 YEMP_MILFLAG.05_2023 = MIL05 YEMP_MILFLAG.06_2023 = MIL06 YEMP_MILFLAG.07_2023 = MIL07 YEMP_MILFLAG.08_2023 = MIL08 YEMP_MILFLAG.09_2023 = MIL09 YEMP_MILFLAG.10_2023 = MIL10; array UID [10] UID01-UID10; array CUR [10] CUR01-CUR10; array HRS [10] HRS01-HRS10; array MIL [10] MIL01-MIL10; array STDAY [10] STD01-STD10; array STM [10] STM01-STM10; array STY [10] STY01-STY10; array BDTE [10] BDTE01-BDTE10; do i=1 to 10; if stday(i)<=0 and stday(i)>-4 then stday(i)=1; end; 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 [10] END01-END10; array ENM [10] ENM01-ENM10; array ENY [10] ENY01-ENY10; array EDTE [10] EDTE01-EDTE10; do i=1 to 10; if end(i)<0 and end(i)>-4 then end(i)=28; end; 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; 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; if stm01=-5 then cps21=-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; cps21=-4; loc=1; end; do i=1 to 10; if MIL(i)=1 then do; EDTE(i)=.; HRS(i)=.; UID(i)=.; CUR(i)=.; end; end; 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 then do; cps21=i; loc=2; end; end; do i=1 to 10; if cps21=. and edte(i) ne . and edte(i) ne -3 then dtemax=max(edte01, edte02, edte03, edte04, edte05, edte06, edte07, edte08, edte09, edte10); end; do i=1 to 10; if cps21=. and edte(i)=-3 then dtemax=-3; end; count=0; do i=1 to 10; if dtemax>-3 and dtemax=edte(i) then count=count+1; end; do i=1 to 10; if cps21=. and count=1 and dtemax>-3 and dtemax=edte(i) then do; cps21=i; loc=3; end; end; if cps21=. 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; cps21=-4; loc=4; end; curcnt=0; do i=1 to 10; if cps21=. and cur(i)=1 then curcnt=curcnt+1; end; do i=1 to 10; if cps21=. and curcnt=1 and cur(i)=1 then do; cps21=i; curflg=1; loc=5; end; end; do i=1 to 10; if cps21=. and dtemax>-3 and edte(i)>0 and dtemax ne edte(i) then do; hrs(i)=.; bdte(i)=.; end; if cps21=. and dtemax=-3 and edte(i)=-3 then do; hrs(i)=.; end; end; do i=1 to 10; if cps21=. 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 cps21=. and hrscnt=1 and hrsmax=hrs(i) and hrsmax ne . then do; cps21=i; loc=7; end; end; do i=1 to 10; if cps21=. and hrsmax=hrs(i) and dtemax=-3 and edte(i)>0 then do; cps21=i; loc=8; end; end; do i=1 to 10; if cps21=. and hrsmax ne . and hrselg=1 and hrsmax ne hrs(i) then bdte(i)=.; end; do i=1 to 10; if cps21=. 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; do i=1 to 10; if cps21=. 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 cps21=. and begcnt=1 and dtemin>-3 and dtemin=bdte(i) then do; cps21=i; loc=9; end; end; do i=1 to 10; if cps21=. and dtemin ne bdte(i) and dtemin>-3 then bdte(i)=.; end; do i=1 to 10; if cps21=. and dtemin=bdte(i) and dtemin>-3 then do; cps21=i; loc=10; end; end; do i=1 to 10; if cps21=. and hrsmax=hrs(i) and dtemin=-3 and bdte(i)>0 then do; cps21=i; loc=11; end; end; do i=1 to 10; if cps21=. and dtemax>-3 and hrs(i)=-3 then do; cps21=-3; loc=6; end; end; if cps21=. then do; cps21=-3; loc=12; end; do i=1 to 10; if hrs(i)=0 then hrs0_f1=1; end; do i=1 to 10; if hrs(i)=0 & cps21=i then hrs0_f2=1; end; run;