Hello,
I have a dataset:
ID_1 | Value |
A | 1 |
A | 2 |
A | 3 |
B | 4 |
B | 5 |
B | 6 |
C | 7 |
C | 8 |
I want to make ID_1 unique and create new columns for all the values. So I want:
ID_1 | Value_1 | Value_2 | Value_3 |
A | 1 | 2 | 3 |
B | 4 | 5 | 6 |
C | 7 | 8 |
Hope someone can help me. Thanks!
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;
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;
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;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.