BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kz134
Obsidian | Level 7

Hello,

 

I have a dataset: 

 

ID_1 Value
A1
A2
A3
B4
B5
B6
C7
C8

 

I want to make ID_1 unique and create new columns for all the values. So I want: 

 

ID_1Value_1Value_2Value_3
A123
B456
C78 

 

Hope someone can help me. Thanks! 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

data have;
input ID_1 $	Value;
cards;
A	1
A	2
A	3
B	4
B	5
B	6
C	7
C	8
;

proc transpose data=have out=want prefix=value;
by id_1;
var value;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

data have;
input ID_1 $	Value;
cards;
A	1
A	2
A	3
B	4
B	5
B	6
C	7
C	8
;

proc transpose data=have out=want prefix=value;
by id_1;
var value;
run;
PeterClemmensen
Tourmaline | Level 20

Do like this

 

data have;
input ID_1 $ Value;
datalines;
A 1
A 2
A 3
B 4
B 5
B 6
C 7
C 8
;

proc transpose data=have out=want(drop=_NAME_) prefix=value_;
    by ID_1 ;
    var Value;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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