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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.