SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
michelconn
Quartz | Level 8

 

proc report data=results2;
column Name Agencyorcompany State location_state ans_per;
define Location_state / group;
define Agencyorcompany / 'Agency or Compary';
define location_state / 'IP Location';
define ans_per / 'Percent Answered' f=percent7.0;
break after Location_state/summarize skip page;
compute after Location_state;
Location_state="Total %";
endcomp;
run;

 

 

Hello All,

 

I am running the code above but am running into issues with the summarize option. In the above code I am summarizing percentages by state. A few of the group only have one value so I would like to avoid summarizing those group. Any idea how I would supress the summary variable for those groups? I could use proc print but it forces me include the grand total which I do not want. 

 

Thanks

3 REPLIES 3
ArtC
Rhodochrosite | Level 12

You can control the values to be displayed in a compute block.

options missing=' ';
proc report data=sashelp.class(where=(age gt 14));
   column age name  height=ht_n height;
   define age / order;
   define name / display;
   define ht_n / n noprint;
   define height / mean;
   break after age / summarize;
   compute after age;
      if ht_n <2 then do;
         height.mean=.;
         age=.;
      end;
   endcomp;
   run;

There is only one 16 year old in the CLASS data.

michelconn
Quartz | Level 8
data results2;
	set results2;
	temp=location_state;
proc report data=results2;
	column Name Agencyorcompany State location_state temp ans_per ans_per=ans_per_n;
	define ans_per_n / n noprint;
	define Agencyorcompany / 'Agency or Compary';
	define location_state / group noprint;
	define temp / 'IP Location State';
	define ans_per / 'Percent Answered' f=percent7.0 sum;
	break after Location_state/summarize skip page;
	compute after Location_state;
		temp="Total %";
		if ans_per_n < 2 then do;
			ans_per.sum=.;
			temp="";
		end;
	endcomp;
run;

Thanks, that almost got me where I want. I made it so that if ans_per has only one row the summarize row displays nothing. Is there a way to make it so there is no summarize row? 

 

Since I am using the page option each group is printing out as an individual table and would like to remove the summarize row for groups with only one row.

ArtC
Rhodochrosite | Level 12

I can't test or research right now but you might be able to add something like the following to your compute block.

call define(_row_,'style','style={cellheight=.1in}');

This won't solve the problem.  You will need to specify some other attributes perhaps eliminate the margins.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1244 views
  • 1 like
  • 2 in conversation