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
SAS Super FREQ
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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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