A little sorting and updating does the trick 🙂
data have;
input ID Date:date11. Value1 Value2;
format Date date11.;
datalines;
1 14-Oct-17 . .
1 15-Oct-17 . .
1 16-Oct-17 . .
1 17-Oct-17 . .
1 18-Oct-17 . .
1 19-Oct-17 1 2
1 20-Oct-17 . .
1 21-Oct-17 . .
1 22-Oct-17 2 5
1 23-Oct-17 . .
1 24-Oct-17 . .
2 14-Oct-17 . .
2 15-Oct-17 . .
2 16-Oct-17 . .
2 17-Oct-17 4 6
2 18-Oct-17 . .
2 19-Oct-17 . .
2 20-Oct-17 . .
2 21-Oct-17 . .
2 22-Oct-17 . .
;
data temp;
update have(obs=0) have;
by ID;
output;
run;
proc sort data=temp;
by ID descending Date;
run;
data temp2;
update temp(obs=0) temp;
by ID;
output;
run;
proc sort data=temp2 out=want;
by ID Date;
run;
proc datasets lib=work nolist;
delete temp:;
run;