The SAS Output Delivery System and reporting techniques

PROC REPORT Summarizing columns

Reply
New Contributor
Posts: 2

PROC REPORT Summarizing columns

I need to create a "Weekday Total" that sums up the Weekdays (Sun- Sat) at the end(bottom) of the report output. I know I need to add a compute and possibly an rbreak, but I am not sure how to do this. Thanks in advance!

 

PROC REPORT NOWD DATA=WORK.WEEKLY_TOTALS BOX SPLIT='\'
STYLE (HEADER)={JUST=center FOREGROUND=white BORDERCOLOR=BLACK BACKGROUND=#201F73 font_weight=bold}
STYLE (REPORT)={CELLSPACING=5 BORDERCOLOR=BLACK};

TITLE1 "QA Sendbacks - Weekday Totals";
/*TITLE2 'UM PROJECTS';*/

COLUMNS LOB CLIENT SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY WEEKLY_TOTAL;

define LOB / DISPLAY style(column)=[cellwidth=0.70in];
DEFINE CLIENT / DISPLAY "CLIENT" style(column)=[cellwidth=2.0in];
define SUNDAY / DISPLAY FORMAT=COMMA9. style(column)=[cellwidth=0.65in];
define MONDAY / DISPLAY FORMAT=COMMA9. style(column)=[cellwidth=0.65in];
define TUESDAY/ DISPLAY FORMAT=COMMA9. style(column)=[cellwidth=0.65in];
define WEDNESDAY / DISPLAY FORMAT=COMMA9. style(column)=[cellwidth=0.65in];
define THURSDAY / DISPLAY FORMAT=COMMA9. style(column)=[cellwidth=0.65in];
define FRIDAY / DISPLAY FORMAT=COMMA9. style(column)=[cellwidth=0.65in];
define SATURDAY / DISPLAY FORMAT=COMMA9. style(column)=[cellwidth=0.65in];
define WEEKLY_TOTAL / DISPLAY FORMAT=COMMA9. style(column)=[cellwidth=0.65in];


compute LOB;
count+1;
if mod(count,2) then do;
call define(_row_, "style", "style=[background=grayf0]");
end;
endcomp;
run;
quit;

SAS Super FREQ
Posts: 9,433

Re: PROC REPORT Summarizing columns

Hi:
Well, you can try
RBREAK AFTER / SUMMARIZE;

and see whether that gives you the grand total you want. Since you didn't post data, nobody can run your program without making some fake data that might be wrong. You have everything as a usage of DISPLAY, which could imply that it is already summarized down to the LOB and CLIENT level or could imply that you have multiple rows per LOB and CLIENT. Hard to say.

Also, since WEEKLY_TOTALS is a usage of display, that implies you've already calculated that value. The ability to label the grand total line from the RBREAK statement with the string "Weekday Totals" will depend on whether LOB is character or numeric and whether the size of LOB (if character) is big enough to hold the string "Weekday Totals".

You show the use of ODS style overrides, but you do NOT show which destination (HTML, RTF, PDF) you want to create. You show the BOX option, which is incompatible with ODS and so that part of your code is confusing.

This would be an easier question to answer if you had posted some sample data or worked up an example using SASHELP data. And, it might have been faster for you to get an answer if you had searched in the forum for previous PROC REPORT questions relating to RBREAK or COMPUTE.

I'd recommend starting with the RBREAK statement and going from there.

Cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 68 views
  • 0 likes
  • 2 in conversation