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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 577 views
  • 0 likes
  • 2 in conversation