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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

Register now

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