BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Altal
Calcite | Level 5

Hi All,

Is there a way in PROC REPORT to have more than one variable in rows. This can be easily done with proc tabulate, but I'm not sure for report procedure...

For example, I'm interested in the following, with variables Age, gender, treatment which are categorical variables, and some other continuous variable that I'm calculating mean for... these are just examples, if doable I'm interested in adding many other categorical variables in rows.

          Treatment A          Treatment B

          N     Mean             N Mean

Age

<65     50     60               90     55

>=65   40     70               100     90

Gender

F          60     55               100     45

M          30     60               90      60



thanks for help

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

For these types of reports, I prefer to pre-process my data and then use proc report to display. 

You can see more details in Cynthia Zender's paper on complex reports. 

http://www2.sas.com/proceedings/forum2008/173-2008.pdf

View solution in original post

4 REPLIES 4
Reeza
Super User

For these types of reports, I prefer to pre-process my data and then use proc report to display. 

You can see more details in Cynthia Zender's paper on complex reports. 

http://www2.sas.com/proceedings/forum2008/173-2008.pdf

PGStats
Opal | Level 21

You can, for instance, transpose your data, like this:

proc transpose data=sashelp.class out=classLong;
by name sex age;
var height weight;
run;

proc format;
value ageclass
low - 12 = "Young"
13 - high = "Old";
run;

proc report data=classlong nowd;
format age ageclass.;
columns _name_ sex age,col1;
define _name_ / group "";
define sex / group format=$3.;
define age / across;
define col1 / mean "Mean" format=8.2;
run;

Report like Tabulate.PNG

PG

PG
Altal
Calcite | Level 5

Thanks you both of you guys...

Cynthia_sas
SAS Super FREQ

HI, To answer your original question, yes, you can get two variables or items under an ACROSS variable with PROC REPORT, as seen in the code below. But, you can only have AGE in the AGE column on the report (as shown in the example), so you cannot "stack" different variables (such as AGE and then a different demographic variable) on top of each other as you can with TABULATE.

   However, for the type of demographic report that you need to create, either of the methods already posted are probably better alternatives. I prefer to "massage" my data as shown in the Complex Reports paper, but transposing is also a good alternative.

Cynthia


ods _all_ close;

ods html file='c:\temp\two_under.html' style=sasweb;

 

proc report data=sashelp.class nowd;

  column age sex,(n weight);

  define age / group;

  define sex / across 'Counts and Averages by Gender';

  define n / 'Count';

  define weight/ mean 'Avg Wt';

run;

   

ods html close;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 867 views
  • 3 likes
  • 4 in conversation