BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I need help to do the following: I have a data set in this form:
ID F G
1 x a
1 y b
1 z c
2 x d
2 y e
2 z f
3 x g
3 y h
3 z i

Now I want to have the following data set:
ID x y z
1 a b c
2 d e f
3 g h i

How to do it? Thanks. Message was edited by: firephoenix
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi,
Let's assume that your dataset is called WORK.MYDATA and that it has the 3 variables that you showed. This PROC TRANSPOSE step would create a dataset in the form that you wanted. The only thing you might have to do is delete the automatic variable _NAME_ that PROC TRANSPOSE creates.
[pre]
proc transpose data=mydata out=d_trans;
by id;
id f;
var g;
run;

options nocenter;
proc print data=d_trans;
title 'transposed data';
run;

[/pre]

And the results would be:
[pre]
transposed data

Obs id _NAME_ x y z

1 1 g a b c
2 2 g d e f
3 3 g g h i

[/pre]

For more help with PROC TRANSPOSE, you might consider reading the documentation on PROC TRANSPOSE and/or contacting Tech Support.

cynthia
deleted_user
Not applicable
Thank you very much.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 657 views
  • 0 likes
  • 2 in conversation