BookmarkSubscribeRSS Feed
ginger2
Calcite | Level 5

ginger2_0-1750790805232.png

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;

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26
/* 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).

--
Paige Miller
Ksharp
Super User
/* UNTESTED CODE */
data have;
 set have;
 id=1;
run;
data want;
  update have(obs=0) have;
  by id;
  output;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 543 views
  • 2 likes
  • 3 in conversation