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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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