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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 705 views
  • 1 like
  • 2 in conversation