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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 2 replies
  • 1022 views
  • 0 likes
  • 3 in conversation