The SAS Output Delivery System and reporting techniques

Adding Custom SubTotal headings in Proc report

Reply
N/A
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.
SAS Super FREQ
Posts: 8,739

Re: Adding Custom SubTotal headings in Proc report

Hi:
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...
[pre]
break after division / summarize;
compute after division;
division= 'SubTotal for '||trim(division);
endcomp;
[/pre]

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.

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 138 views
  • 0 likes
  • 2 in conversation