DATA Step, Macro, Functions and more

Proc Tabulate Totals

Accepted Solution Solved
Reply
Super Contributor
Posts: 497
Accepted Solution

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;

     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.


Two Levels.png

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

Re: Proc Tabulate Totals

Posted in reply to DavidPhillips2

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;

 

View solution in original post


All Replies
Super User
Posts: 11,343

Re: Proc Tabulate Totals

Posted in reply to DavidPhillips2

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,028

Re: Proc Tabulate Totals

Posted in reply to DavidPhillips2

Just Guess:

 

  class gender residency ethnicity academic_period_desc;

 

-->

  class gender ;

class residency ;

class  ethnicity ;

class academic_period_desc;

SAS Super FREQ
Posts: 8,865

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: 11,343

Re: Proc Tabulate Totals

Posted in reply to DavidPhillips2

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;

 

Super Contributor
Posts: 497

Re: Proc Tabulate Totals

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

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 377 views
  • 0 likes
  • 4 in conversation