BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
djbateman
Lapis Lazuli | Level 10

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
1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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

3 REPLIES 3
data_null__
Jade | Level 19

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;
data_null__
Jade | Level 19

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

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;

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
  • 3 replies
  • 1769 views
  • 6 likes
  • 3 in conversation