hi,
I have a dataset like this;
ID A B C D
1 21 45 90 76
1 25 32 78 21
2 34 74 34 89
2 43 88 12 94
2 54 33 77 90
I want to do transposing and the desired o/p will be like
ID _name_ value
1 A 21
1 B 45
1 C 90
1 D 76
1 A 25
1 B 32
1 C 78
1 D 21
2 A 34
2 B 74
2 C 34
2 D 89
...............and so on...
how can i do this?
data have;
input ID A B C D;
datalines;
1 21 45 90 76
1 25 32 78 21
2 34 74 34 89
2 43 88 12 94
2 54 33 77 90
;
data want(keep= ID _name_ value);
set have;
array _{4} A B C D;
do i=1 to dim(_);
_name_=vname(_[i]);
value=_[i];
output;
end;
run;
data have;
input ID A B C D;
datalines;
1 21 45 90 76
1 25 32 78 21
2 34 74 34 89
2 43 88 12 94
2 54 33 77 90
;
data want(keep= ID _name_ value);
set have;
array _{4} A B C D;
do i=1 to dim(_);
_name_=vname(_[i]);
value=_[i];
output;
end;
run;
thank you somuch. it works
Anytime, glad to help 🙂
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.
Ready to level-up your skills? Choose your own adventure.