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 Group | Number of Subjects |
---|---|
White | 1006 |
Asian | 28 |
Black | 98 |
Other | 4 |
Unknown | 20 |
Total | 1156 |
You can use RBREAK and omit the dummy variable.
You can use CALL DEFINE.
You can use RBREAK and omit the dummy variable.
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.