Hi
I have a dataset that looks like this:
| a | b | c | d | e |
|---|---|---|---|---|
| 1 | 3 | 5 | 7 | 9 |
| 2 | 4 | 6 | 8 | 10 |
How to change it to:
| Character | Number |
|---|---|
| a | 1 |
| a | 2 |
| b | 3 |
| b | 4 |
| c | 5 |
| c | 6 |
| d | 7 |
| d | 8 |
| e | 9 |
| e | 10 |
Thank you in advance!
TRANSPOSE :: Base SAS(R) 9.4 Procedures Guide, Third Edition
data have;
input a b c d e;
cards;
1 3 5 7 9
2 4 6 8 10
;
run;
proc transpose data=have out=have;
run;
proc transpose data=have out=have;
by _name_;
run;
Hello,
A data step solution:
data have;
input a b c d e;
datalines;
1 3 5 7 9
2 4 6 8 10
;
data want;
set have;
array vars{*} a--e;
do i=1 to dim(vars);
character=vname(vars{i});
number=vars{i};
output;
end;
keep character number;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.