@VinitvictorCorr wrote:
lets say
data k;
input subject $ height weight bmi;
datalines;
abc 198 87 22.5
pqr 209 98 25
;
run;
Try this:
data want;
set k;
array vars _numeric_;
length name $32 value 8;
do i = 1 to dim(vars);
name = vname(vars{i});
value = vars{i};
output;
end;
keep subject name value;
run;
Difficult to say without your showing how you want the data transposed. As @Ksharp mentioned, I was part of a team that wrote two macros for transposing and untransposing SAS datasets. You can find the code and info for each at:
https://github.com/gerhard1050/Untranspose-a-Wide-File
https://communities.sas.com/t5/SAS-Communities-Library/A-better-way-to-FLIP-i-e-transpose-make-wide-...
http://support.sas.com/resources/papers/proceedings13/538-2013.pdf
Art, CEO, AnalystFinder.com
@VinitvictorCorr wrote:
I need a work around for Proc Transpose. Can you suggest anything?
Going from long to wide or wide to long?
Really specific examples really do help as when a "simple" proc transpose doesn't work perhaps two (or more transposes) and merging results; or proc sql with reflexive joins; or sometime even using a report procedure such as tabulate to create an output data set and manipulating.
datastep
Thank you for the solutions guys. Much appreciated 🙂
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 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.