BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Kurt_Bremser
Super User

@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;
VinitvictorCorr
Quartz | Level 8
thanks :). Was looking for something like this..
Ksharp
Super User

@art297  wrote a macro %transpose for that . @Reeza  also mentioned it many times .

art297
Opal | Level 21

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

 

ballardw
Super User

@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.

VinitvictorCorr
Quartz | Level 8
I need the output like:-
subject vstestcd vsorres
34reqrwe
Quartz | Level 8

datastep

VinitvictorCorr
Quartz | Level 8

Thank you for the solutions guys.  Much appreciated 🙂

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 22 replies
  • 2485 views
  • 2 likes
  • 9 in conversation