BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
twildone
Pyrite | Level 9

Hi...I am trying to insert subtotals after each "Degree Original" and Totals after each School. I was able to get the Grand Total and tried to include "All" after "School" and "Degree Original" in the Table statement and it didn't work. Do I need to use parenthesis to group the variables. Thanks.

 

proc tabulate data=List201 format=8.0 style=[bordercolor=black];	
    var StudentUID1 / style=[background=lightblue bordercolor=black];
    var 'Completion Status1'n / style=[background=lightblue bordercolor=black];
    var Graduation1 / style=[background=lightblue bordercolor=black];
	class Gender / style=[background=lightblue bordercolor=black] order=unformatted;
	class "Season Enrolled1"n /	style=[background=lightblue vjust=c bordercolor=black] order=unformatted;
	class School /	style=[background=lightblue vjust=c bordercolor=black] order=unformatted missing;
	class "Initial Program"n / style=[background=lightblue bordercolor=black] order=unformatted missing;
	class Level / style=[background=lightblue bordercolor=black] order=unformatted missing ;
	class Academic_Term / style=[background=lightblue bordercolor=black] order=unformatted missing;
    class 'Degree Original'n / style=[background=lightblue vjust=c bordercolor=black] order=unformatted missing;
    classlev Gender  / style=[background=lightblue bordercolor=black];
    classlev "Initial Program"n / style=[background=lightblue cellwidth=11.0cm vjust=c bordercolor=black];
    classlev Level / style=[background=lightblue cellwidth=3.0cm bordercolor=black];
    classlev "Season Enrolled1"n / style=[background=lightblue cellwidth=3.0cm vjust=c bordercolor=black];
    classlev School / style=[background=lightblue cellwidth=4.0cm vjust=c bordercolor=black];
    classlev Academic_Term / style=[background=lightblue cellwidth=3.0cm  vjust=c bordercolor=black];
    classlev 'Degree Original'n / style=[background=lightblue cellwidth=6.0cm vjust=c bordercolor=black];    

    table School= 'School' * "Degree Original"n='Credential' * "Initial Program"n='Program' * Level='Level' All ={ label='Grand Total' S=[background = lightblue bordercolor=black]} *[style=[bordercolor=black]] , ((StudentUID1='Students Enrolled' * Gender=' ' * Sum=' ' ) ("Season Enrolled1"n=' '  * Gender=' ' * N=' ' ) ('Completion Status1'n='On-Time Rate (%)' * Gender=' ' * (pctsum<Gender>=""*f=8.2) ) (Graduation1='Graduation Rate (%)' * Gender=' ' * (pctsum<Gender>=""*f=8.2) )) /  box=[label=' ' style=[backgroundcolor=lightblue cellwidth=10.0cm  bordercolor=black]];
;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Suggestion: For questions relating to calculation or content of reports providing a LOT of style overrides just makes code long.

Providing data, or using a data set provided in the SASHELP library for examples is also helpful.

 

See if this example helps. It uses a data set you should have available.

proc tabulate data=sashelp.class;
   class age sex;
   var height;

   table (age all='overall total')*(sex all='Age total'),
         height *(n mean)
   ;
run;

General idea is to include an All with a nested variable in parentheses to get the subtotals for the higher levels.

 


@twildone wrote:

Hi...I am trying to insert subtotals after each "Degree Original" and Totals after each School. I was able to get the Grand Total and tried to include "All" after "School" and "Degree Original" in the Table statement and it didn't work. Do I need to use parenthesis to group the variables. Thanks.

 

proc tabulate data=List201 format=8.0 style=[bordercolor=black];	
    var StudentUID1 / style=[background=lightblue bordercolor=black];
    var 'Completion Status1'n / style=[background=lightblue bordercolor=black];
    var Graduation1 / style=[background=lightblue bordercolor=black];
	class Gender / style=[background=lightblue bordercolor=black] order=unformatted;
	class "Season Enrolled1"n /	style=[background=lightblue vjust=c bordercolor=black] order=unformatted;
	class School /	style=[background=lightblue vjust=c bordercolor=black] order=unformatted missing;
	class "Initial Program"n / style=[background=lightblue bordercolor=black] order=unformatted missing;
	class Level / style=[background=lightblue bordercolor=black] order=unformatted missing ;
	class Academic_Term / style=[background=lightblue bordercolor=black] order=unformatted missing;
    class 'Degree Original'n / style=[background=lightblue vjust=c bordercolor=black] order=unformatted missing;
    classlev Gender  / style=[background=lightblue bordercolor=black];
    classlev "Initial Program"n / style=[background=lightblue cellwidth=11.0cm vjust=c bordercolor=black];
    classlev Level / style=[background=lightblue cellwidth=3.0cm bordercolor=black];
    classlev "Season Enrolled1"n / style=[background=lightblue cellwidth=3.0cm vjust=c bordercolor=black];
    classlev School / style=[background=lightblue cellwidth=4.0cm vjust=c bordercolor=black];
    classlev Academic_Term / style=[background=lightblue cellwidth=3.0cm  vjust=c bordercolor=black];
    classlev 'Degree Original'n / style=[background=lightblue cellwidth=6.0cm vjust=c bordercolor=black];    

    table School= 'School' * "Degree Original"n='Credential' * "Initial Program"n='Program' * Level='Level' All ={ label='Grand Total' S=[background = lightblue bordercolor=black]} *[style=[bordercolor=black]] , ((StudentUID1='Students Enrolled' * Gender=' ' * Sum=' ' ) ("Season Enrolled1"n=' '  * Gender=' ' * N=' ' ) ('Completion Status1'n='On-Time Rate (%)' * Gender=' ' * (pctsum<Gender>=""*f=8.2) ) (Graduation1='Graduation Rate (%)' * Gender=' ' * (pctsum<Gender>=""*f=8.2) )) /  box=[label=' ' style=[backgroundcolor=lightblue cellwidth=10.0cm  bordercolor=black]];
;
run;

 

View solution in original post

2 REPLIES 2
ballardw
Super User

Suggestion: For questions relating to calculation or content of reports providing a LOT of style overrides just makes code long.

Providing data, or using a data set provided in the SASHELP library for examples is also helpful.

 

See if this example helps. It uses a data set you should have available.

proc tabulate data=sashelp.class;
   class age sex;
   var height;

   table (age all='overall total')*(sex all='Age total'),
         height *(n mean)
   ;
run;

General idea is to include an All with a nested variable in parentheses to get the subtotals for the higher levels.

 


@twildone wrote:

Hi...I am trying to insert subtotals after each "Degree Original" and Totals after each School. I was able to get the Grand Total and tried to include "All" after "School" and "Degree Original" in the Table statement and it didn't work. Do I need to use parenthesis to group the variables. Thanks.

 

proc tabulate data=List201 format=8.0 style=[bordercolor=black];	
    var StudentUID1 / style=[background=lightblue bordercolor=black];
    var 'Completion Status1'n / style=[background=lightblue bordercolor=black];
    var Graduation1 / style=[background=lightblue bordercolor=black];
	class Gender / style=[background=lightblue bordercolor=black] order=unformatted;
	class "Season Enrolled1"n /	style=[background=lightblue vjust=c bordercolor=black] order=unformatted;
	class School /	style=[background=lightblue vjust=c bordercolor=black] order=unformatted missing;
	class "Initial Program"n / style=[background=lightblue bordercolor=black] order=unformatted missing;
	class Level / style=[background=lightblue bordercolor=black] order=unformatted missing ;
	class Academic_Term / style=[background=lightblue bordercolor=black] order=unformatted missing;
    class 'Degree Original'n / style=[background=lightblue vjust=c bordercolor=black] order=unformatted missing;
    classlev Gender  / style=[background=lightblue bordercolor=black];
    classlev "Initial Program"n / style=[background=lightblue cellwidth=11.0cm vjust=c bordercolor=black];
    classlev Level / style=[background=lightblue cellwidth=3.0cm bordercolor=black];
    classlev "Season Enrolled1"n / style=[background=lightblue cellwidth=3.0cm vjust=c bordercolor=black];
    classlev School / style=[background=lightblue cellwidth=4.0cm vjust=c bordercolor=black];
    classlev Academic_Term / style=[background=lightblue cellwidth=3.0cm  vjust=c bordercolor=black];
    classlev 'Degree Original'n / style=[background=lightblue cellwidth=6.0cm vjust=c bordercolor=black];    

    table School= 'School' * "Degree Original"n='Credential' * "Initial Program"n='Program' * Level='Level' All ={ label='Grand Total' S=[background = lightblue bordercolor=black]} *[style=[bordercolor=black]] , ((StudentUID1='Students Enrolled' * Gender=' ' * Sum=' ' ) ("Season Enrolled1"n=' '  * Gender=' ' * N=' ' ) ('Completion Status1'n='On-Time Rate (%)' * Gender=' ' * (pctsum<Gender>=""*f=8.2) ) (Graduation1='Graduation Rate (%)' * Gender=' ' * (pctsum<Gender>=""*f=8.2) )) /  box=[label=' ' style=[backgroundcolor=lightblue cellwidth=10.0cm  bordercolor=black]];
;
run;

 

twildone
Pyrite | Level 9

Hi BallardW....nesting the variable in parenthesis was what was needed. It work now....thanks

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 367 views
  • 0 likes
  • 2 in conversation