/************************************************ create interview date and age on DOI; int_m CV_INTERVIEW_DATE~M int_y CV_INTERVIEW_DATE~Y AGEM CV_AGE_MONTHS_INT_DATE AGEYR CV_AGE_INT_DATE int_cm CV_INTERVIEW_CMONTH ************************************************/ /*********************************************************** ** QNAME Variable Name ** SYMBOL_CURDATE~M_2021 INT_M SYMBOL_CURDATE~Y_2021 INT_Y SYMBOL_KEY_BDATE~M_2021 BDATE_M SYMBOL_KEY_BDATE~Y_2021 BDATE_Y *************************************************************/ ***** Create AGEM, R's age in month; if ( int_y>0 and bdate_y>0 and int_m>0 and bdate_m>0) then AGEM= (int_y-bdate_y)*12+ (int_m-bdate_m) ; else AGEM=.; ***** Create AGEYR, R's age in year; if (int_m>0 and int_y>0 and bdate_m>0 and bdate_y>0) then do; if int_m>bdate_m then AGEYR=int_y-bdate_y; else if int_m<=bdate_m then AGEYR=int_y-bdate_y-1; end; else AGEYR=.; /* Create int_cm, interview date in continous month. */ if (int_y >0 and int_m>0 ) then int_cm=int_m+12*(int_y-1980); else int_cm=.; /* Taking care of non interviewers. */ if INT_Y =-5 then do; INT_m =-5; INT_Y =-5; int_cm=-5; bdate_m=-5; bdate_y=-5; AGEM=-5; AGEYR=-5; end; ***** generate the output data; filename out 'out_int_dateR20.dat'; data null; set two; file out lrecl=70 recfm=v dlm=',' dsd; put norcid int_m int_y AGEYR AGEM int_cm; run;