05-04-2017 05:31 PM
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;
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.
05-05-2017 02:11 AM
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.
05-05-2017 11:25 AM
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.
05-05-2017 12:17 PM
I can't test or research right now but you might be able to add something like the following to your compute block.
This won't solve the problem. You will need to specify some other attributes perhaps eliminate the margins.