BookmarkSubscribeRSS Feed
krm
Obsidian | Level 7 krm
Obsidian | Level 7

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

5 REPLIES 5
Cynthia_sas
SAS Super FREQ
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
krm
Obsidian | Level 7 krm
Obsidian | Level 7

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

 

Ksharp
Super User

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;
Ksharp
Super User

 

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

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

krm
Obsidian | Level 7 krm
Obsidian | Level 7

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

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
  • 5 replies
  • 2776 views
  • 0 likes
  • 3 in conversation