BookmarkSubscribeRSS Feed
JasonL
Quartz | Level 8

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

2 REPLIES 2
ballardw
Super User

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.

JasonL
Quartz | Level 8

Great!  That does it!

Thank you very much!

 

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!

What is Bayesian Analysis?

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.

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
  • 2 replies
  • 376 views
  • 1 like
  • 2 in conversation