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;
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;
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;
Hi BallardW....nesting the variable in parenthesis was what was needed. It work now....thanks
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.