BookmarkSubscribeRSS Feed
shubham_d
Fluorite | Level 6

Have - 

idvar1var2var3
1101102103

 

data d1;

input id var1 var2 var3;

datalines;

1 101 102 103

;

run;

 

Want - 

 

idcodes
1101
1102
1103

 

And in case var1,var2,var3 is null, then want dataset should not contain an entry for it. For example - If var3 is null then want dataset - 

 

idcodes
1101
1102

 

Thanks in advance for any kind of help 🙂

1 REPLY 1
Kathryn_SAS
SAS Employee

You can use the following PROC TRANSPOSE to do this:

data have;
input id var1 var2 var3;
cards;
1 101 102 .
;
run;

proc transpose data=have out=want(drop=_name_ where=(col1 ne .));
by id;
var var1 var2 var3;
run;

proc print data=want;
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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 647 views
  • 0 likes
  • 2 in conversation