/* Cross-round training variables as of R19 */ /* dlitrnM /* 'CVC_TRN_CERT_DATE~M */ /* dlitrnY /* 'CVC_TRN_CERT_DATE~Y */ /* dlitrnCRT /* 'CVC_TRN_CERT */ /* R20 training variables */ /* Month day and year stopped attending training that R was attending last interview */ /* T640D1 'YTRN-640.01~D_2021'n */ /* T640M1 'YTRN-640.01~M_2021'n */ /* T640Y1 'YTRN-640.01~Y_2021'n */ /* T640D2 'YTRN-640.02~D_2021'n */ /* T640M2 'YTRN-640.02~M_2021'n */ /* T640Y2 'YTRN-640.02~Y_2021'n */ /* T640D3 'YTRN-640.03~D_2021'n */ /* T640M3 'YTRN-640.03~M_2021'n */ /* T640Y3 'YTRN-640.03~Y_2021'n */ /* T640D4 'YTRN-640.04~D_2021'n */ /* T640M4 'YTRN-640.04~M_2021'n */ /* T640Y4 'YTRN-640.04~Y_2021'n */ /* T640D5 'YTRN-640.05~D_2021'n */ /* T640M5 'YTRN-640.05~M_2021'n */ /* T640Y5 'YTRN-640.05~Y_2021'n */ /* T640D6 'YTRN-640.06~D_2021'n */ /* T640M6 'YTRN-640.06~M_2021'n */ /* T640Y6 'YTRN-640.06~Y_2021'n */ /* T640D7 'YTRN-640.07~D_2021'n */ /* T640M7 'YTRN-640.07~M_2021'n */ /* T640Y7 'YTRN-640.07~Y_2021'n */ /* T640D8 'YTRN-640.08~D_2021'n */ /* T640M8 'YTRN-640.08~M_2021'n */ /* T640Y8 'YTRN-640.08~Y_2021'n */ /* Month, day and year ended training */ /* T1500D1 'YTRN-1500.01~D_2021'n */ /* T1500M1 'YTRN-1500.01~M_2021'n */ /* T1500Y1 'YTRN-1500.01~Y_2021'n */ /* T1500D2 'YTRN-1500.02~D_2021'n */ /* T1500M2 'YTRN-1500.02~M_2021'n */ /* T1500Y2 'YTRN-1500.02~Y_2021'n */ /* T1500D3 'YTRN-1500.03~D_2021'n */ /* T1500M3 'YTRN-1500.03~M_2021'n */ /* T1500Y3 'YTRN-1500.03~Y_2021'n */ /* T1500D4 'YTRN-1500.04~D_2021'n */ /* T1500M4 'YTRN-1500.04~M_2021'n */ /* T1500Y4 'YTRN-1500.04~Y_2021'n */ /* T1500D5 'YTRN-1500.05~D_2021'n */ /* T1500M5 'YTRN-1500.05~M_2021'n */ /* T1500Y5 'YTRN-1500.05~Y_2021'n */ /* T1500D6 'YTRN-1500.06~D_2021'n */ /* T1500M6 'YTRN-1500.06~M_2021'n */ /* T1500Y6 'YTRN-1500.06~Y_2021'n */ /* T1500D9 'YTRN-1500.09~D_2021'n */ /* T1500M9 'YTRN-1500.09~M_2021'n */ /* T1500Y9 'YTRN-1500.09~Y_2021'n */ /* Did R receive certificate, license or degree from training? */ /* T69001 'YTRN-6900.01_2021'n */ /* T69002 'YTRN-6900.02_2021'n */ /* T69003 'YTRN-6900.03_2021'n */ /* T69004 'YTRN-6900.04_2021'n */ /* T69005 'YTRN-6900.05_2021'n */ /* T69006 'YTRN-6900.06_2021'n */ /* T69007 'YTRN-6900.07_2021'n */ /* T69008 'YTRN-6900.08_2021'n */ /* T69009 'YTRN-6900.09_2021'n */ /* Type of certificate/licensing received */ * T70001 'YTRN-7000.01_2021'n */ /* T70002 'YTRN-7000.02_2021'n */ /* T70003 'YTRN-7000.03_2021'n */ /* T70004 'YTRN-7000.04_2021'n */ /* T70006 'YTRN-7000.06_2021'n */ /* PUBID 'PUBID'n */ /* INT_Y 'CV_INTERVIEW_DATE~Y'n */ /* INT_M 'CV_INTERVIEW_DATE~M'n */ /* Start of program code */ data one ; set trn.r20training_vars ; run; proc sort data=one; by pubid; run; /* Read in CVC training variables as of R19 */ data two; set trn.cvc_data; run; proc sort data=two; by pubid; run; /* Merge files by PUBID */ data three; merge one two ; by pubid; if int_Y=. then do; int_Y=-5; int_M=-5; end; /*Initialize variables*/ TRNCERT=.; /*Ever received vocational/completion certificate or state license*/ TRNCMTH=.; /*Month of most recent certificate/license--based on date of completion of most recent cert/lic granting training program*/ TRNCYR=.; /*Year of most recent certificate/license--based on date of completion of most recent cert/lic granting training program*/ /*Defining arrays*/ %let n=9; /*# loops */ array recent(&n); array t6900{&n}; *receive cert; array t7000{&n}; *type of cert; array t1500m{&n}; *end of training (month); array t1500y{&n}; *end of training (year); array t1500cm(&n); *working variable for calendar month; array t640m{&n}; *end of previously in progress training (month); array t640y{&n}; *end of previously in progress training (year); array t640cm(&n); *working variable for calendar month; array T_cm(&n); /* noninterviews */ if int_y=-5 then do; do i=1 to (&n); t6900{i} =-5; t7000{i}=-5; t1500m{i}=-5; t1500y{i}=-5; t1500cm(i)=-5; t640m{i}=-5; t640y{i}=-5; t640cm(i)=-5; end; end; /* initialize variables for interviewed respondents if missing */ if int_y>-5 then do; do i=1 to (&n); if t6900{i} = . then t6900{i} = -4; if t7000{i} = . then t7000{i} = -4; if t1500m{i} = . then t1500m{i} = -4; if t1500y{i} = . then t1500y{i} = -4; if t1500cm(i)= . then t1500cm(i) =-4; if t640m{i}= . then t640m{i} =-4 ; if t640y{i}=. then t640y{i}=-4; if t640cm(i)=. then t640cm(i)=-4; end; end; /* If R completed previously started training, assign month and year from t640 to t1500 variables */ do i=1 to (&n); if t640m{i} >-4 & t640y{i}>-4 & t1500m{i}=-4 then do; t1500m{i}=t640m{i}; t1500y{i}=t640y{i}; t640m{i}=-4; t640y{i}=-4; end; /* If valid training month and year and received a vocational certificate, state license, certificate of completion or other licence, compute calendar months since 1980 */ if t1500m{i} >0 & t1500y{i}>0 & t6900{i}=1 and (1<=t7000{i}<=3 or t7000{i}=8) then do; t1500cm{i}= (t1500y{i}-1980)*12+t1500m{i}; *months since 1980?; end; * choose maximum of dates above; if t1500cm{i}>0 then do; T_cm(&n) = max(of t1500cm1-t1500cm9); /* R20 changed to 9 (number of loops) */ end; end; do i=1 to (&n); if T_cm(&n)>0 then do; do i=516 to 216 by -12; if i-11<=T_cm(&n)<=i then do; TRNCMTH=T_cm(&n)-(i-12); * converts back to month; TRNCYR=(T_cm(&n)-TRNCMTH)/12+1980; * converts back to year; end; end; end; end; if TRNCMTH>-4 then TRNCERT=1; /* if no certificate then do */ do i=1 to (&n); if TRNCERT^=1 then do; if t6900{i}=0 then TRNCERT=0; if t6900{i}=1 and t7000{i}>3 & t7000{i} ne 8 then TRNCERT=0; *certificate types other than 1,2,3,8 are not counted; if t6900{i}=1 and t7000{i}<1 then TRNCERT=0; * if missing type of certificate; end; /* if certificate, but invalid month or year then do */ if t6900{i}=1 and (1<=t7000{i}<=3 or t7000{i}=8) & TRNCMTH = . & ( t1500M(i) in (-1 -2) | t1500Y(i) in (-1 -2)) then do; TRNCMTH=t1500M(i); TRNCYR= t1500Y(i); TRNCERT=1; end; end; /*This part compares values for current round to created vars for previous round(s) to obtain the most recent date of cert/lic receipt*/ if TRNCERT in(. , 0 ,-3 ) & dlitrnCRT in ( -3, 1) then do; TRNCERT=dlitrnCRT; TRNCYR=dlitrnY; TRNCMTH=dlitrnM; end; if TRNCERT=. and dlitrnCRT=0 then do; TRNCERT=dlitrnCRT; TRNCYR=dlitrnY; TRNCMTH=dlitrnM; end; /*if previous report was an invalid skip and there has never been a valid cert reported, this carries that value forward. Rosella says that it was decided to leave the last valid training date with a year as the most recent training date. */ if TRNCERT=1 and dlitrnCRT=1 and dlitrnY>TRNCYR then do; TRNCYR=dlitrnY; TRNCMTH=dlitrnM; end; if TRNCERT=1 and dlitrnCRT=1 and dlitrnY=TRNCYR and dlitrnM>TRNCMTH then do; TRNCMTH=dlitrnM; end; if TRNCYR in (-1,-2) then TRNCYR=-3; *DK/Ref year assigned to -3; if TRNCMTH in (-1,-2) then TRNCMTH=-3; *DK/Ref month assigned to -3; if TRNCERT=. and t69001=-4 then TRNCERT=-4; *no new training reported for interviewed R; if TRNCERT=. and t69001=-5 then TRNCERT=-5; *non-interview; if TRNCERT=. and t69001 in (-1,-2,-3) then TRNCERT=-3; *DK/REF/-3 assigned to -3; /* Refusals (-1) and Don't knows (-2) are all set to -3 for date and certification */ /*if R received training cert but there is no date, then date variables = invalid skip */ if TRNCERT=1 and TRNCMTH<1 then TRNCMTH=-3; if TRNCERT=1 and TRNCYR<1 then TRNCYR=-3; /*if R took training but did not receive training cert then the date variables = valid skip */ if TRNCERT=0 then TRNCMTH=-4; if TRNCERT=0 then TRNCYR=-4; if TRNCERT=-3 then TRNCMTH=-3; if TRNCERT=-3 then TRNCYR=-3; if TRNCERT=-4 then TRNCMTH=-4; if TRNCERT=-4 then TRNCYR=-4; if T640M1=-5 then TRNCMTH=-5; if T640M1=-5 then TRNCYR=-5; /* Non-interviews: assign CVC training variables as of R19 */ if int_y=-5 then do; TRNCERT=dlitrnCRT; TRNCYR=dlitrnY; TRNCMTH=dlitrnM; end; run; /* Write out .csv file with new training variables as of R20 */ keep PUBID TRNCERT TRNCYR TRNCMTH;