I’m trying to display two levels of sub totals and totals. Using three columns such that each column has totals of increasing detail and the grand total at the bottom.
This works for two columns but three I’m running into an issue with three.
Two columns (works)
proc tabulate data=enrollment out=enrollment3;
var enrolled;
class gender residency ethnicity academic_period_desc;
table gender*residency*ethnicity*enrolled=' ' all*residency*enrolled=' ', academic_period_desc;
run;
Three columns (question)
proc tabulate data=enrollment out=enrollment3;
var enrolled;
class gender residency ethnicity academic_period_desc;
table gender*residency*ethnicity*enrolled=' ' all*residency*enrolled=' ' all*residency*ethnicity*enrolled=' ', academic_period_desc;
run;
Two level example is attached.
You might be looking for multiple uses of All to get the different subtotals.
table (gender all)*(residency all)*(ethnicity all)*enrolled=' ' ,
academic_period_desc;
You might describe what doesn't work.
You may want to investigate some code like
(all residency)*enrolled
(all residency)*ethnicity*enrolled
to see if that gives a better grouping for whay you are doing.
And provide example data if you want something testable.
BTW you example table output does not show "ethnicity" but the code you say works and generates the output includes ethnicity.
Just Guess:
class gender residency ethnicity academic_period_desc;
-->
class gender ;
class residency ;
class ethnicity ;
class academic_period_desc;
You might be looking for multiple uses of All to get the different subtotals.
table (gender all)*(residency all)*(ethnicity all)*enrolled=' ' ,
academic_period_desc;
Thanks, I was having a really hard time researching this one.
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.