BookmarkSubscribeRSS Feed
daszlosek
Quartz | Level 8

Hello Everyone,

 

I have a dataset with calculated outputs using SAS-callable SQL (one observation per a variable) and it is structured like this:

 

SAS Output from proc report:

 

Var 1

Var 2

Var 3

3165

73

309

 

And I would like it like this:

 

 

 

 

Var1

3165

 

Var2

73

 

Var3

309

 

 

 

I have tried using the across statement in proc report, but all it does is add a one underneath each column in the longitudinal graph. I also thought about using proc transpose, but I am not sure if it would work in this case, plus I would prefer to be able to use proc reports ability to rename columns (except in this case they would be rows). Here is my code:

 

proc report data = test nowd;
columns var1 var2 var3;

 

define var1 / style(COLUMN)={JUST=l CELLWIDTH=35}
                     style(HEADER)={JUST=l CELLWIDTH=35}
                      "Variable 1" order
;
define var2    / style(COLUMN)={JUST=l CELLWIDTH=35}
                     style(HEADER)={JUST=l CELLWIDTH=35}
                      "Variable 2" order
;

define var3    / style(COLUMN)={JUST=l CELLWIDTH=35}
                     style(HEADER)={JUST=l CELLWIDTH=35}
                      "Variable 3" order
;

run;

 

 

Thank you!

2 REPLIES 2
Steelers_In_DC
Barite | Level 11

Transpose will work:

 

data have;
input var1 var2 var3;
cards;
3165 73 309
;

proc transpose data=have out=want;var var:;

 

If the variables are numeric you do not need the var statement. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

There is a whole raft of guidance and help on this topic, you are looking for reshaping data from wide to long in this case.  Here is one document:

http://www.ats.ucla.edu/stat/sas/modules/ltow_transpose.htm

 

But a search on here or the web will result in many pages on the topic to fit the many scenarios possible.

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

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.

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
  • 739 views
  • 0 likes
  • 3 in conversation