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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.