Assuming your data has already sorted by date. data have;
input col1_ID col2_date : mmddyy10. col3 ;
format col2_date mmddyy10.;
cards;
100 03/04/2014 0.5
100 04/04/2014 0.6
100 05/04/2014 0.3
102 01/05/2014 0.9
102 06/08/2014 0.6
102 08/09/2016 0.6
103 02/05/2015 0.6
103 03/04/2014 0.6
103 04/04/2014 0.5
103 05/06/2014 0.7
;
run;
%let today='17apr2014'd ;
data want;
merge have have(firstobs=2 keep=col1_ID col2_date rename=(col1_ID=_id col2_date=_date));
if (col1_ID eq _id) and ( col2_date lt &today lt _date) then col4=col3;
drop _: ;
run;
Xia Keshan
... View more