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!
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.