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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 799 views
  • 1 like
  • 2 in conversation