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;

SAS Innovate 2025: Register Now

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!

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
  • 1060 views
  • 0 likes
  • 2 in conversation