data have;
input ID1 ID2 $ Value1 Value2;
cards;
1 A 2 3
2 A 4 5
;
run;
data want;
input ID1 ID2 $ Type $ Value;
cards;
1 A Value1 2
1 A Value2 3
2 A Value1 4
2 A Value2 5
;
run;
Basically keep ID1 and ID2, and then reshape column 3 and column 4.
How to achieve it? Thanks!
As Bruno says you need Proc Transpose for this but you'll also want to do some renaming e.g.
proc transpose data=have out=want(rename=(_name_=type col1=value)); by id1 id2; var value1 value2; run;
You can use Proc TRANSPOSE to do this.
Use BY statement for your id vars and the VAR statement for the vars to you want to transpose.
As Bruno says you need Proc Transpose for this but you'll also want to do some renaming e.g.
proc transpose data=have out=want(rename=(_name_=type col1=value)); by id1 id2; var value1 value2; run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.