@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 🙂
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.