Help using Base SAS procedures

Proc Tabulate: 1 Variable and Present as Row

Reply
Frequent Contributor
Posts: 75

Proc Tabulate: 1 Variable and Present as Row

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!

Regular Contributor
Posts: 161

Re: Proc Tabulate: 1 Variable and Present as Row

[ Edited ]

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
Frequent Contributor
Posts: 75

Re: Proc Tabulate: 1 Variable and Present as Row

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

Regular Contributor
Posts: 161

Re: Proc Tabulate: 1 Variable and Present as Row

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
Ask a Question
Discussion stats
  • 3 replies
  • 358 views
  • 0 likes
  • 2 in conversation