Hi everyone,
I'm trying to fill in empty cells using the value from the first non-missing cell to the left of that empty cell in each row. The table runs from January 1, 2014 through August 1, 2018. For example:
I tried:
data desiredtable;
set rawtable;
if variable=. then lag(variable);
end;
run;
But seems like this only works if the table was set up in long format vs. wide format.
Any help is appreciated. Thanks.
-Aidan
Like this?
data HAVE;
input A B C D E F G H ;
cards;
. 1 . 2 3 . . .
run;
data WANT;
set HAVE;
array ARR [8] A -- H ;
do I=2 to 8;
if ARR[I]=. then ARR[I]=ARR[I-1];
end;
run;
Thanks Chris it worked!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.