Solved
Valued Guide
Posts: 619

# Proc Tabulate Totals

[ Edited ]

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;

table gender*residency*ethnicity*enrolled=' ' all*residency*enrolled=' ', academic_period_desc;

run;

Three columns (question)

proc tabulate data=enrollment  out=enrollment3;

var enrolled;

table gender*residency*ethnicity*enrolled=' ' all*residency*enrolled=' ' all*residency*ethnicity*enrolled=' ', academic_period_desc;

run;

Two level example is attached.

Accepted Solutions
Solution
‎03-18-2016 10:21 AM
Super User
Posts: 13,583

## Re: Proc Tabulate Totals

You might be looking for multiple uses of All to get the different subtotals.

table (gender all)*(residency all)*(ethnicity all)*enrolled=' ' ,

All Replies
Super User
Posts: 13,583

## Re: Proc Tabulate Totals

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.

Super User
Posts: 10,784

## Re: Proc Tabulate Totals

Just Guess:

-->

class gender ;

class residency ;

class  ethnicity ;

SAS Super FREQ
Posts: 9,371

## Re: Proc Tabulate Totals

Hi, there's no benefit to multiple CLASS statements unless you are specifying different options on each CLASS statement.
cynthia
Solution
‎03-18-2016 10:21 AM
Super User
Posts: 13,583

## Re: Proc Tabulate Totals

You might be looking for multiple uses of All to get the different subtotals.

table (gender all)*(residency all)*(ethnicity all)*enrolled=' ' ,

Valued Guide
Posts: 619

## Re: Proc Tabulate Totals

Thanks, I was having a really hard time researching this one.

🔒 This topic is solved and locked.