Hi,
I have a sample dataset below.
data scores;
input
team $5. score ;
datalines;
TeamA 43
TeamA 12
TeamA 43
TeamB 54
TeamB 23
TeamB 43
;
I am using break and rbreak statements to get row totals as below:
proc report nowd data=scores
style(header)=[color=blue font_weight = bold]
style(column)=[color=black fontfamily=helvetica] spanrows;
columns
(team
score);
define team / order;
define score / center;
break after team / dul summarize;
rbreak after / dol summarize;
run;
I am getting the following result:
TeamA | 43 |
12 | |
43 | |
TeamA | 98 |
TeamB | 54 |
23 | |
43 | |
TeamB | 120 |
218 |
Does Proc Report let the user to customize the totals?
Such as - Changing the summary labels and fonts as below:
TeamA | 43 |
12 | |
43 | |
Team A Total | 98 |
TeamB | 54 |
23 | |
Team B Total | 43 |
TeamB | 120 |
Overall Score | 218 |
Thank you
Hi @Cynthia_sas, as I mentioned in the previous post I was able to figure out renaming the row totals.
In the example below I have been trying to get the row totals also for the computed fields. When I use the code below I am getting blank fields as the result.
data scores;
input
team $5. score against;
datalines;
TeamA 43 23
TeamA 12 14
TeamA 43 24
TeamB 54 63
TeamB 23 45
TeamB 43 45
;
proc report nowd data=scores spanrows;
columns
(team score against ratio);
define team / order;
define score / center;
define against / center;
define ratio / computed center;
compute ratio;
ratio=score/against;
endcomp;
rbreak after / summarize;
run;
TeamA | 43 | 23 | . |
12 | 14 | . | |
43 | 24 | . | |
TeamB | 54 | 63 | . |
23 | 45 | . | |
43 | 45 | . | |
218 | 214 | . |
Does proc report have the functionality to create computed summary fields such as below ?
team | score | against | ratio |
TeamA | 43 | 23 | 1.86956522 |
12 | 14 | 0.85714286 | |
43 | 24 | 1.79166667 | |
TeamB | 54 | 63 | 0.85714286 |
23 | 45 | 0.51111111 | |
43 | 45 | 0.95555556 | |
Totals | 218 | 214 | 1.01869159 |
Try this one. The variable reference is not right. Their usage is ANALYSIS, so you need refer to them as AGE.SUM .
data scores;
input
team $5. score against;
datalines;
TeamA 43 23
TeamA 12 14
TeamA 43 24
TeamB 54 63
TeamB 23 45
TeamB 43 45
;
proc report nowd data=scores spanrows;
columns
(team score against ratio);
define team / order;
define score / center;
define against / center;
define ratio / computed center;
compute ratio;
ratio=score.sum/against.sum;
endcomp;
compute after;
team='Total';
endcomp;
rbreak after / summarize;
run;
compute after team;
team=cats(team ,'Total');
endcomp;
But you need enough long length of TEAM to hold that string .
@Cynthia_sas thank you for the direction. I found the documentation and all was clear.
proc report nowd data=scores
style(header)=[color=blue font_weight = bold]
style(column)=[color=black fontfamily=helvetica] spanrows;
columns
(team
score);
define team / order;
define score / center;
break after team / dul summarize style=[background=lightgrey foreground=black font_weight=bold];
rbreak after / dol summarize style=[background=lightgrey foreground=black font_weight=bold];
compute team;
if _break_ ne ' ' then
call define('team','style','style=[posttext=" Total"]');
endcomp;
run;
Thank you.
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.