How to use retain to fill in the missing A and B and C
Here is the code so far to make this dataset:
data PROD_ALL;
set _PROD_ALL;
if B=strip('Subject ID') then delete;
if missing(G) then delete;
run;
/* UNTESTED CODE */
data want;
set have;
retain a1 b1 c1;
if not missing(a) then a1=a;
if not missing(b) then b1=b;
if not missing(c) then c1=c;
run;
This code is untested, because we cannot work with data in a screen capture. To get tested code, please provide the data as working SAS data step code (instructions and examples).
/* UNTESTED CODE */
data have;
set have;
id=1;
run;
data want;
update have(obs=0) have;
by id;
output;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.