Hi, I am using a macro like this below to select the last non null date in a de-duping process. %macro retbl(nvar=age,i=1); data kplastn&i; set datasrt(keep=&nvar hosp_visit_id event_Time); length tempn 8.; by hosp_visit_id evnt_Time; retain tempn; if first.hosp_visit_id then tempn=.; if missing(&nvar) then &nvar = input(tempn, 8.); else tempn=input(&nvar,??8.); if last.hosp_visit_id ; run; %mend; %retbl(nvar=Date_Time,i=6) This works fine unless the date is missing for all the data except only one valid entry. illustration: input data: obs Date_time 1 . 2 . 3 05APR15:10:40:20 4 . 5 . output data set obs Date_time 1 . desired output data set obs Data_time 1. 05APR15:10:40:20 Thanksa
... View more