data temp3;
input @1 grp 1. @5 dt yymmdd10.;
format dt date10.;
datalines;
1 2019-03-11
2 2018-12-15
2 .
2 .
3 2018-12-28
3 .
;
Can someone let me know how to get the missing values populated with previous date+5 days in the particular group.
For example in the group 2, I want to see the below result.
2 2018-12-15
2 2018-12-20
2 2018-12-25
Thanks in advance!
data temp3;
infile cards truncover;
input @1 grp 1. @5 dt yymmdd10.;
format dt date10.;
datalines;
1 2019-03-11
2 2018-12-15
2 .
2 .
3 2018-12-28
3 .
;
data want;
set temp3;
by grp;
retain _dt;
if not missing(dt) or first.grp then _dt=dt;
else if missing(dt) then do; dt=_dt+5;_dt=dt;end;
drop _dt;
run;
data temp3;
infile cards truncover;
input @1 grp 1. @5 dt yymmdd10.;
format dt date10.;
datalines;
1 2019-03-11
2 2018-12-15
2 .
2 .
3 2018-12-28
3 .
;
data want;
set temp3;
by grp;
retain _dt;
if not missing(dt) or first.grp then _dt=dt;
else if missing(dt) then do; dt=_dt+5;_dt=dt;end;
drop _dt;
run;
Thank you!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.