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 Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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