The SAS Output Delivery System and reporting techniques

Add Summary in PROC REPORT

Accepted Solution Solved
Reply
Regular Contributor
Posts: 220
Accepted Solution

Add Summary in PROC REPORT

I am trying to add a simple summary line to my report.  I am sure this will be an easy fix.

I have a list of races and counts per race.  I want to add a line that says "Total" in the race column and the sum of the counts in the count column.  I also want that total line to be bold.  Here is what I have attempted.  I can't get the "Total" text to appear, and I don't know where to start to make it bold.

data race;

      input race $ count;

   flag='x';

      cards;

White    1006

Asian    28

Black    98

Other    4

Unknown  20

;

run;

proc report data=race nowindows;

      column flag race count;

      define flag / group noprint;

      define race / display left 'Racial Group';

      define count / sum 'Number of Subjects';

      break after flag / summarize;

      compute after flag;

       race='Total';

      endcomp;

run;

Desired outcome:

Racial GroupNumber of Subjects
White1006
Asian28
Black98
Other4
Unknown20
Total1156

Accepted Solutions
Solution
‎06-26-2013 10:31 AM
Respected Advisor
Posts: 3,777

Re: Add Summary in PROC REPORT

You can use RBREAK and omit the dummy variable.

data race;
   input race $ count;
   cards;
White    1006
Asian    28
Black    98
Other    4
Unknown  20
;;;;
run;



proc report data=race nowindows;
  
column race count;
   define race / display left 'Racial Group';
  
define count / sum 'Number of Subjects';
  
rbreak after / summarize;
  
compute after;
      race=
'Total';
     
call define(_row_, "style", "STYLE=[font_weight=bold]");
      endcomp;
  
run;

View solution in original post


All Replies
Respected Advisor
Posts: 3,777

Re: Add Summary in PROC REPORT

You can use CALL DEFINE.

data race;
   input race $ count;
   retain flag 'x';
  
cards;
White    1006
Asian    28
Black    98
Other    4
Unknown  20
;;;;
run;



proc report data=race nowindows;
  
column flag race count;
   define flag / group noprint;
  
define race / display left 'Racial Group';
  
define count / sum 'Number of Subjects';
  
break after flag / summarize;
  
compute after flag;
      race='Total';
     
call define(_row_, "style", "STYLE=[font_weight=bold /*BACKGROUND=cxFFFF82]*/");
      endcomp;
  
run;
Solution
‎06-26-2013 10:31 AM
Respected Advisor
Posts: 3,777

Re: Add Summary in PROC REPORT

You can use RBREAK and omit the dummy variable.

data race;
   input race $ count;
   cards;
White    1006
Asian    28
Black    98
Other    4
Unknown  20
;;;;
run;



proc report data=race nowindows;
  
column race count;
   define race / display left 'Racial Group';
  
define count / sum 'Number of Subjects';
  
rbreak after / summarize;
  
compute after;
      race=
'Total';
     
call define(_row_, "style", "STYLE=[font_weight=bold]");
      endcomp;
  
run;
SAS Super FREQ
Posts: 8,743

Re: Add Summary in PROC REPORT

Hi,

  Even more streamlined syntax, without using CALL DEFINE is possible.

cynthia

   

ods html file='c:\temp\total.html' style=sasweb;

proc report data=race nowd

   style(summary)={font_weight=bold foreground=green};

   column race count;

   define race / display left 'Racial Group';

   define count / sum 'Number of Subjects';

   rbreak after / summarize;

   compute after;

      race='Total';

   endcomp;

   run;

ods html close;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 293 views
  • 6 likes
  • 3 in conversation