/************************************************ 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 ************************************************/ /***************************************************************************************************** **Variable Names on the Gator Variable Names in the Program********************************** PUBID PUBID SYMBOL_CURDATE~M INT_M SYMBOL_CURDATE~Y INT_Y SYMBOL_KEY_BDATE~M BDATE_M SYMBOL_KEY_BDATE~Y BDATE_Y ******************************************************************************************************/ options nocenter validvarname=any;options nocenter validvarname=any; *---Read in space-delimited ascii file; data one; infile 'int_dateR21.dat' lrecl=31 missover DSD DLM=' ' print; input pubid norcid BDATE_M BDATE_Y INT_M INT_Y ; run; data two; set one; ***** 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; proc freq; table int_m int_y AGEYR AGEM int_cm; ***** generate the output data; filename out 'out_int_dateR21.dat'; data null; set two; file out lrecl=70 recfm=v dlm=',' dsd; put norcid int_m int_y AGEYR AGEM int_cm; run;