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
SAS Super FREQ

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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