BookmarkSubscribeRSS Feed
tburus
Obsidian | Level 7

I am making a somewhat complicated summary table in PROC REPORT where I want to summarize within each group variable and summarize the group variables themselves. Here is a picture of what I have (with flags included):

plot.png

There are two things I want to accomplish:

  1. I want to provide overall summaries for 'Competition' and 'Practice' event types at the top, under the 'Overall Total' summary
  2. I want to suppress the sport names that are being duplicated

Is this possible? I'd love to do it through PROC REPORT without having to just brute force a new dataset to make it work. Below is my current code:

proc report data=all_t1 nowd split="*"
		style(report)=[frame=hsides rules=none]
		style(header)=[background=white color=&rgreen. borderbottomcolor=black]
		style(lines)=[background=white];
	column sport event_type unweightedinj ae ratio weightedinj flag;
	define sport / group '' format=$sport_cap.;
	define event_type / group 'Event Type' center order=formatted style(column)=[cellwidth=1in just=l];
	define unweightedinj / analysis '# Injuries' format=comma8.0 style(column)=[cellwidth=1in just=c];
	define ae / analysis '# Exposures' format=comma8.0 style(column)=[cellwidth=1in just=c];
	define ratio / computed 'Injury Rate *(per 1,000 AEs)' format=8.2 style(column)=[cellwidth=1.75in just=c];
	compute ratio;
		ratio = unweightedinj.sum/ae.sum*1000;
	endcomp;
	define weightedinj / analysis 'Nationally Estimated *# Injuries' format=comma8.0 style(column)=[cellwidth=1.75in just=c];
	define flag / computed format=$25.;  

	break before sport /summarize style(summary)={font_weight=bold};
	rbreak before /summarize style(summary)={font_weight=bold};
	compute sport;
		if _break_ = '_RBREAK_' then sport = 'Overall';
	endcomp;
	compute event_type;
    	if _break_ = 'sport' then event_type = 'Total';
		if _break_ = '_RBREAK_' then event_type = 'Total';
	endcomp;
	compute flag / CHAR;                   
      flag=_BREAK_;                          
   	endcomp;  
run;
1 REPLY 1
MCoopmans
SAS Employee

Hello,

 

I simulated your question with the SASHELP.CARS dataset, and think I found a solution to your second question:

 

ODS _ALL_ close;
ODS listing;

PROC REPORT DATA=SASHELP.CARS LS=93  PS=80  SPLIT="/" CENTER ;
COLUMN  Origin DriveTrain EngineSize Cylinders MPG_Highway;

DEFINE  Origin / GROUP FORMAT= $8. WIDTH=10    SPACING=2   LEFT "Origin" ;
DEFINE  DriveTrain / GROUP FORMAT= $5. WIDTH=10    SPACING=2   LEFT "DriveTrain" ;
DEFINE  EngineSize / SUM FORMAT= BEST9. WIDTH=9     SPACING=2   RIGHT "Engine Size (L)" ;
DEFINE  Cylinders / SUM FORMAT= BEST9. WIDTH=9     SPACING=2   RIGHT "Cylinders" ;
DEFINE  MPG_Highway / SUM FORMAT= BEST9. WIDTH=9     SPACING=2   RIGHT "MPG (Highway)" ;

BREAK BEFORE Origin / SUMMARIZE ;

RBREAK BEFORE  / SUMMARIZE ;

compute drivetrain ;
    	if _break_ = 'Origin' then drivetrain = 'Total';
		if _break_ = '_RBREAK_' then drivetrain = 'Total';
	endcomp;

compute origin;
	if _break_ = '_RBREAK_' then origin = 'Overall';
	else if _break_ ne 'Origin' then origin = " ";
endcomp;
RUN;

ODS _ALL_ close;

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 552 views
  • 0 likes
  • 2 in conversation