BookmarkSubscribeRSS Feed
shubham_d
Fluorite | Level 6

Have - 

idnum1num2num3
1101102103

 

data d1;

input id num1 num2 num3;

datalines;

1 101 102 103

;

run;

 

Want - 

 

idnum_list
1101
1102
1103


Incase either of num1, num2, num3 is null then I don't want their entries in the dataset. For example - If num3 is null then dataset should be -

 

idnum_list
1101
1102


Thanks in advance 🙂 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Easiest thing to do is simply delete the unwanted rows from the output.

--
Paige Miller
shubham_d
Fluorite | Level 6
Hey! Deleting unwanted rows is fine. But how would I transpose keeping the ID same & creating a new column for this transpose? Basically the dataset of Want
PaigeMiller
Diamond | Level 26

Run PROC TRANSPOSE with the following in the code

 

by id;

 

 

 

--
Paige Miller
Tom
Super User Tom
Super User

@shubham_d wrote:
Hey! Deleting unwanted rows is fine. But how would I transpose keeping the ID same & creating a new column for this transpose? Basically the dataset of Want

You probably need to make more test data that actually demonstrates the issues you are having (or are worried about).

 

If you want the re-transposed data to end up in the same variable names then you need to either keep the _NAME_ variable that PROC TRANSPOSE generates (or something that can be used to re-create it) to use in the ID statement of PROC TRANSPOSE.

proc transpose data=have out=TALL(where=(not missing(col1)) ;
   by id;
   var var1-var3 ;
run;
proc tranpose data=TALL out=WIDE(drop=_name_);
  by id;
  id _name_;
  var col1;
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
  • 4 replies
  • 439 views
  • 0 likes
  • 3 in conversation