BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ayin
Quartz | Level 8
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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisBrooks
Ammonite | Level 13

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;

View solution in original post

2 REPLIES 2
BrunoMueller
SAS Super FREQ

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.

ChrisBrooks
Ammonite | Level 13

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 2 replies
  • 1714 views
  • 2 likes
  • 3 in conversation