BookmarkSubscribeRSS Feed
apple
Calcite | Level 5

Hi

 

Using SAS 7.1.

 

I only have 1 variable, but instead of presenting in column, I want in ROWS. How do I do that?

 

Thanks!

3 REPLIES 3
kannand
Lapis Lazuli | Level 10

Would it be possible to share some of your data as sample and tell us how you expect the output to look like?

Kannan Deivasigamani
apple
Calcite | Level 5

Hi,

 

THank you for the reply.

I have attached a sample.

 

I could do a transpose paste in excel, but as I have many tables it becomes tedious. Hence would prefer that SAS generate the tables as ROWS.

 

THank you

kannand
Lapis Lazuli | Level 10

Here is something you may clone to your specific needs.... This is just one way of getting the output you desire... a bit lengthy but simple code....

 

data have;
input v1:$5. v2:$5. v3:$5. v4:$5.;
datalines;
Tom Peter Henry Jack 
100 101 102 103
;
run;

data name;
 set have;
 if _n_ = 1;
run;
proc transpose data=name out=names(drop=_name_);
  var v1 v2 v3 v4;
run;
data id;
 set have;
 if _n_ = 2;
run;
proc transpose data=id out=ids(drop=_name_);
  var v1 v2 v3 v4;
run;
data final;
 set names(rename=(col1=name));
 set ids(rename=(col1=id));
run;
proc print data=final;
run;

It produces the following output for your reference...

 

Obs	name	id
1	Tom	100
2	Peter	101
3	Henry	102
4	Jack	103

Hope this helps...!!! Good Luck...!!!

Kannan Deivasigamani

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1377 views
  • 0 likes
  • 2 in conversation