Help using Base SAS procedures

Proc report like proc tabulate?

Accepted Solution Solved
Reply
Contributor
Posts: 62
Accepted Solution

Proc report like proc tabulate?

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


Accepted Solutions
Solution
‎11-18-2013 09:48 PM
Super User
Posts: 19,878

Re: Proc report like proc tabulate?

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


All Replies
Solution
‎11-18-2013 09:48 PM
Super User
Posts: 19,878

Re: Proc report like proc tabulate?

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

Respected Advisor
Posts: 4,937

Re: Proc report like proc tabulate?

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
Contributor
Posts: 62

Re: Proc report like proc tabulate?

Thanks you both of you guys...

SAS Super FREQ
Posts: 8,869

Re: Proc report like proc tabulate?

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;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 265 views
  • 3 likes
  • 4 in conversation