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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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