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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.