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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.