The SAS Output Delivery System and reporting techniques

Adding Custom SubTotal headings in Proc report

Not applicable
Posts: 0

Adding Custom SubTotal headings in Proc report

I am using Proc report to create an Excel file using ODS. There is a variable called Division that I sub-total on but have now been asked to added a more descriptive name such as: Sub-Totals for Division = North and East (where North & East is the division name) and changes for each value of division in the file. I assume there is a way to create a macro for this but am not sure how to do this. Any help would be appreciated.
Posts: 9,373

Re: Adding Custom SubTotal headings in Proc report

Posted in reply to deleted_user
I'm don't think that you need a Macro variable or macro program for this task.

PROC REPORT allows you to assign a text string to a report column at the break with a COMPUTE AFTER block...
break after division / summarize;
compute after division;
division= 'SubTotal for '||trim(division);

Assuming that the length of the Division variable was long enough for the whole text string (including the spaces), then you would get the customized text at the break. Of course, if Division is only 15 characters in length, then the string 'SubTotal for ' is going to take up 13 characters -- so you'd have to use some other techniques to get your customized break text. It is all still possible with PROC REPORT without using macro variables.

Reading the PROC REPORT documentation and examples or contacting Tech Support would be your best bet for help with this task if you are not familiar with PROC REPORT COMPUTE blocks.

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation