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

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 3 replies
  • 1768 views
  • 1 like
  • 2 in conversation