Hi there,
I have data like this:
ID V1 V2 V3 ...... V20
01 A1 B2 C3 ......
02 O1 P2 Q3 ......
03 X1 Y2 Z3 ......
......
and need to convert it into something like this:
ID TheVar
01 A1
01 B2
01 C3
......
02 O1
02 P2
02 Q3
......
03 X1
03 Y2
03 Z3
......
Is there an efficient way to do that? Thank you!
Jason
Proc transpose:
data have; input iD $ V1 $ v2 $ V3 $; datalines; 01 A1 B2 C3 02 O1 P2 Q3 03 X1 Y2 Z3 ; proc transpose data=have out=trans (drop=_name_) prefix=TheVar ; by id; var v1 - v3; run;
If there are other variables that need to be carried along you need to show a better example.
Please provide data in the form of a data step as shown above and post into a code box opened on the forum using the </> or "running man" icon. Posting the main message window will usually result in text being reformatted and data steps may not run after the forum gets through with them.
Great! That does it!
Thank you very much!
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.