data vy1;
set vy;
/*Seperate date into day, month, year */
dayc=substr(date,1,2);
monthc=substr(date,3,3);
yearc=substr(date,6,4);
if yearc ne "unkk" then do; /*One row has year missing, not able to impute */
/*both month and day missing*/
if dayc="uk" and monthc="unk" then do;
dayi="31";
monthi="DEC";
end;
/*only day missing*/
if dayc="uk" and monthc ne"unk" then do;
myrc=cats(monthc)||cats(yearc);
myn=input(myrc, anydtdte7.);
lastday=intnx('month',myn,0,'E');
end;
/*get imputed date*/
if dayi ne "" and monthi ne "" then
date_impc=cats(dayi)||cats(monthi)||cats(yearc);
if lastday ne . then date_impc=put(lastday, date9.);
format date_imp date9.;
date_imp=input(date_impc, date9.);
end;
run;
... View more