BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidPhillips2
Rhodochrosite | Level 12

 

 

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
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

5 REPLIES 5
ballardw
Super User

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.

Ksharp
Super User

Just Guess:

 

  class gender residency ethnicity academic_period_desc;

 

-->

  class gender ;

class residency ;

class  ethnicity ;

class academic_period_desc;

Cynthia_sas
Diamond | Level 26
Hi, there's no benefit to multiple CLASS statements unless you are specifying different options on each CLASS statement.
cynthia
ballardw
Super User

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;

 

DavidPhillips2
Rhodochrosite | Level 12

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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