BookmarkSubscribeRSS Feed
jmhill
Calcite | Level 5

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;

1 REPLY 1
Cynthia_sas
Diamond | Level 26
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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 987 views
  • 0 likes
  • 2 in conversation