I have a dataset:
id | name | dm | value |
101 | weight | ds | 50 |
101 | weight | ds | 55 |
101 | weight | ds | 54 |
101 | weight | ds | 49.8 |
101 | weight | ds | 53 |
i need to output:
id | dm | weight |
101 | ds | 50 |
101 | ds | 55 |
101 | ds | 54 |
101 | ds | 49.8 |
101 | ds | 53 |
using proc transpose how can i do it?
The following seems to work:
data have;
input id name $ dm $ value;
datalines;
101 weight ds 50
101 weight ds 55
101 weight ds 54
101 weight ds 49.8
101 weight ds 53
;
proc sort data = have;
by id dm value;
run;
proc transpose data = have out = want;
by id dm value;
var value;
id name;
run;
But why? Why not just rename "value" to "weight" and drop "name" if you really need that specific structure?
The following seems to work:
data have;
input id name $ dm $ value;
datalines;
101 weight ds 50
101 weight ds 55
101 weight ds 54
101 weight ds 49.8
101 weight ds 53
;
proc sort data = have;
by id dm value;
run;
proc transpose data = have out = want;
by id dm value;
var value;
id name;
run;
But why? Why not just rename "value" to "weight" and drop "name" if you really need that specific structure?
thanx that worked
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.