I've been looking for a way to fill null values with previous non-null values within the same group.
While I know how to do that in SQL it took me a while to figure out in SAS.
I have been able to figure out the code that will accomplish this. However, I'd like this to apply to only about 10 variables of about 100 variables I have in my data set.
is there a way to apply the update to only selected variables with the below code?
data Want;
update MyData(obs=0) MyData;
by ID;
output;
run;
proc print data=Want;
run;
Thanks in advance !
Just re-read those variables from the dataset.
Let's day you want to update only VAR1-VAR5 .
data Want;
update MyData(obs=0) MyData ;
by ID;
set MyData (drop=Var1-Var5);
output;
run;
Hi @Tom , thanks for the reply.
In your suggestion below, wouldn't the output data only contain VAR1-VAR5?
Ultimately I need the output dataset to contain all 100 variables VAR1-VAR100 but only retro-fill VAR1-VAR5.
Thanks !
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.