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
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.
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.
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;
PG
Thanks you both of you guys...
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;
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!
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.