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

Dear All, 

 

I want to impute the missing obs with previous value, but have no idea, though I referred below good link: https://communities.sas.com/t5/SAS-Programming/Last-Observation-Carried-Foward/m-p/309339#M66511

 

Yes, all the missing variable should be imputed from the previous value, as this would be the accumulative number of subjects till some timepoint. 

 

The datafile in xlsx has been attached. 

 

Thank you. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The generic way to carry over is this:

data want;
set have;
retain _var1;
if var1 ne . /* if var1 is numeric, otherwise "" */
then _var1 = var1;
else var1 =_var1;
drop _var1;
run;

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

The generic way to carry over is this:

data want;
set have;
retain _var1;
if var1 ne . /* if var1 is numeric, otherwise "" */
then _var1 = var1;
else var1 =_var1;
drop _var1;
run;
Jack2012
Obsidian | Level 7
Perfect, that is what I want.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 889 views
  • 1 like
  • 2 in conversation