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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1273 views
  • 0 likes
  • 2 in conversation