The SAS Output Delivery System and reporting techniques

How to rename row totals in proc report?

Reply
Contributor krm
Contributor
Posts: 26

How to rename row totals in proc report?

[ Edited ]

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:

 

team score
TeamA43
 12
 43
TeamA98
TeamB54
 23
 43
TeamB120
 218

 

Does Proc Report let the user to customize the totals?

 

Such as - Changing the summary labels and fonts as below:

 

team score
TeamA43
 12
 43
Team A Total98
TeamB54
 23

 Team B Total

43
TeamB120
 Overall Score218

 

Thank you

SAS Super FREQ
Posts: 8,645

Re: How to rename row totals in proc report?

Hi:
Please look in the PROC REPORT documentation at the COMPUTE block examples. You can customize the BREAK and RBREAK lines. You just need to do it in a COMPUTE block. Not at a place where I can write code, but I believe the documentation is quite clear and there may also be previous forum postings on this subject.
cynthia
Contributor krm
Contributor
Posts: 26

Re: How to rename row totals in proc report?

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;

 

 

 

team score against ratio
TeamA4323.
 1214.
 4324.
TeamB5463.
 2345.
 4345.
 218214.


Does proc report have the functionality to create computed summary fields such as below ?

 

teamscoreagainstratio
TeamA43231.86956522
 12140.85714286
 43241.79166667
TeamB54630.85714286
 23450.51111111
 43450.95555556
 Totals2182141.01869159

 

Grand Advisor
Posts: 9,325

Re: How to rename row totals in proc report?

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;
Grand Advisor
Posts: 9,325

Re: How to rename row totals in proc report?

[ Edited ]

 

compute after team;
 team=cats(team ,'Total');
endcomp;

But you need enough long length of TEAM to hold that string .

Contributor krm
Contributor
Posts: 26

Re: How to rename row totals in proc report?

@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.

Post a Question
Discussion Stats
  • 5 replies
  • 455 views
  • 0 likes
  • 3 in conversation