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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1112 views
  • 0 likes
  • 4 in conversation