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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 227 views
  • 0 likes
  • 2 in conversation