BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shari
Calcite | Level 5

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!  

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
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;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20
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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1283 views
  • 0 likes
  • 2 in conversation