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
Diamond | Level 26
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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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