Hi All,
I have a sas report that has two sub totals named as 'TOTAL' (file attached). I would like to calculate the ''Grand Total' which I have colored in yellow.
I have tried using the following code to calculate the GRAND TOTAL but as expected it adds the sub totals as well and shows the result 76 in place of 38.
more code .......
rbreak after / SUMMARIZE style={color=yellow} ;
compute after;
Academics = 'GRAND TOTAL';
endcomp;
run;
I have not created the "TOTAL" in the Proc report. Rather I have created them in Proc Sql and then used the UNION function to add it to the table before I created the Proc report.
Hence I am unsure of how to get the GRAND TOTAL which should select only the observations namely (leaving , new, old, continue, previous, Interna.) to calculate the 'GRAND TOTAL'.
Please suggest the correct procedure.
Thank you!
Rs
Hi: You do not need to pre-calculate the subtotal. For example, consider this report produced from 2 regions in SASHELP.SHOES:
The BREAK statement produced the subtotal for each region and the RBREAK statement computed the GRAND TOTAL. The challenge if you pre-calculate the subtotals and put them in the data, is that then you have to turn around and exclude them from the grand total unless you pre-calculate the grand total too. It makes more sense to let PROC REPORT (or TABULATE) do it for you.
Cynthia
Thank you for your suggestion.
Can you please provide a example of how to add selective observations using proc means as is in my case?
If you provide sample data. What does your data look like to start with?
@75063 wrote:
Thank you for your suggestion.
Can you please provide a example of how to add selective observations using proc means as is in my case?
Hi: You do not need to pre-calculate the subtotal. For example, consider this report produced from 2 regions in SASHELP.SHOES:
The BREAK statement produced the subtotal for each region and the RBREAK statement computed the GRAND TOTAL. The challenge if you pre-calculate the subtotals and put them in the data, is that then you have to turn around and exclude them from the grand total unless you pre-calculate the grand total too. It makes more sense to let PROC REPORT (or TABULATE) do it for you.
Cynthia
Thank you Cynthia for your explanation and advice. I think proc Report is a better and smoother way to carry out the operation in this case.
Regards,
Rs
@75063 please mark Cynthia answer as correct, not your own.
I am not sure why the labels for "subtotal" and "grand total" cannot be shown in my excel output. Any idea what's going on?
Thanks,
Hi,
Yes, you are correct. After correcting the report order, there is no problem at all. Thanks again,
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.