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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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