Date: Thu, 10 Mar 2005 14:19:36 -0500
Reply-To: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject: Re: My PROC REPORT ignorance
On Wed, 9 Mar 2005 12:38:30 -0800, Jeff Voeller <Jeff.Voeller@MCI.COM> wrote:
>After years of looking the other way, I'm finally forcing myself to use
>PROC REPORT. For plain text output, I've always been so comfortable
>with DATA _NULL_ that I never really pursued PROC REPORT, but in these
>days of HTML it's obvious that I can and should create prettier output.
>
>I'm stuck on something that I think should be doable, but I'm missing
>some hopefully simple piece. Yes, I've RTFM--repeatedly--but just can't
>seem to get this one.
>
>I want to create a report with the columns Error (character), CallCount
>(numeric) and NetCost (numeric). If CallCount is not missing or zero, I
>want the row to be red. If CallCount is missing or zero, I want it to
>be green. At the very end of the report, I want totals for CallCount
>and NetCost.
>
>What I'm finding is that I can either get the color coding or I can get
>the totals, but I just can't get both! This code gives me the color
>coding but gives me an empty #99FF99 colored line for a summary:
>
>proc report data=excepts.err_summary;
> column HiLevel ErrorNum Error CallCount NetCost;
> define HiLevel/order noprint;
> define ErrorNum/order noprint;
> define Error/display;
> define CallCount/display format=comma15. 'Call Count';
> define NetCost/display format=dollar18.2 'Net Cost';
> break before HiLevel/style={background=#CCCCCC font_weight=bold};
> compute before HiLevel;
> line HiLevel $hlv.;
> endcomp;
> compute CallCount;
> if CallCount in(0,.) then
> call define(_row_,"style","style={background=#99FF99}");
> else call define(_row_,"style","style={background=#FF99FF}");
> endcomp;
> rbreak after/summarize style={background=#EEEEEE};
>run;
>
>If I modify the DEFINE statements for CallCount and NetCost to include
>"analysis sum", I get the summary numbers that I want at the bottom
>(though colored #99FF99 rather than #EEEEEE), but I don't get the proper
>coloring for the individual rows--everything is #99FF99 because,
>according to the SAS log, the variable CallCount is uninitialized.
>
>Am I trying to do the impossible or am I just missing something obvious?
>
>Thanks.
Jeff:
Not impossible.
You can use these facts. Error will be blank in summary line.
callCount is an analysis variable. callCount.<statistic> will be
available, but value of the column in a given row is not in callCount
variable; instead the value is in the automatic variable _C<n>_, where
<n> is the column number per the column statement.
So your code would become
define callCount / display analysis;
...
compute CallCount;
if error ne ' ' then do; * not a summary row;
* 4th column in report is callCount;
if _c4_ in (0,.) then
call define(_row_,"style","style={background=red}");
else
call define(_row_,"style","style={background=green}");
end;
endcomp;
|