## PROC REPORT - conditional formatting working for all but one column

Solved
Occasional Contributor
Posts: 7

# PROC REPORT - conditional formatting working for all but one column

Hey everyone, this is my first post so bear with me:

I am attempting to produce a PROC REPORT that has different colors based on score (pretty common, lots of literature). The problem is I am having a phantom problem that nobody in my office can explain. Here is the cose.

proc report data=selected_peds nowd;
where measure='Well Care Visits 7-21 Years'
OR    measure='Well Child Visits 3-6 Years';
column 'Practice Group'n Measure 'Product Line'n denominator score2 target2 QI_2011 'Quality Index (QI)'n;
define 'Practice Group'n / group;
define 'Product Line'n / group;
define measure / group;
define denominator / display "n";
define score2  /  "Measure Score "  display format=percent.;
define target2 /  "Measure Target"  display format=percent.;
define QI_2011 / display 'QI - 2011';
define 'Quality Index (QI)'n / 'QI - 2012' display;

compute 'Quality Index (QI)'n;
if 'Quality Index (QI)'n < QI_2011 then
call define(_col_, 'style', 'style=[foreground=red]');
endcomp;

compute score2;
if score2 < target2 then do;
call define(_col_,'style','style={foreground=red}');
end;
ELSE call define(_col_,'style','style={foreground=green}');

endcomp;

compute target2;
if score2 < target2 then do;
call define(_col_,'style','style={foreground=red}');
end;
ELSE call define(_col_,'style','style={foreground=green}');

endcomp;
run;

now notice something, the compute for score2 and target2 have the exact same logic and yet in the results target2 comes up correct (some green and some red) and score2 does not (all green).

Both variables are formatted the same in the dataset and in the REPORT.

Any ideas?

using base 9.2 with Enterprise Guide 4.3

thanks!

Accepted Solutions
Solution
‎05-21-2013 01:54 PM
Super User
Posts: 23,663

## Re: PROC REPORT - conditional formatting working for all but one column

Somewhere in the middle of the doc:

Base SAS(R) 9.2 Procedures Guide

If a compute block is associated with a report item, then PROC REPORT executes the compute block on every row of the report when it comes to the column for that item. The value of a computed variable in any row of a report is the last value assigned to that variable during that execution of the DATA step statements in the compute block. PROC REPORT assigns values to the columns in a row of a report from left to right. Consequently, you cannot base the calculation of a computed variable on any variable that appears to its right in the report.

All Replies
Solution
‎05-21-2013 01:54 PM
Super User
Posts: 23,663

## Re: PROC REPORT - conditional formatting working for all but one column

Somewhere in the middle of the doc:

Base SAS(R) 9.2 Procedures Guide

If a compute block is associated with a report item, then PROC REPORT executes the compute block on every row of the report when it comes to the column for that item. The value of a computed variable in any row of a report is the last value assigned to that variable during that execution of the DATA step statements in the compute block. PROC REPORT assigns values to the columns in a row of a report from left to right. Consequently, you cannot base the calculation of a computed variable on any variable that appears to its right in the report.

Occasional Contributor
Posts: 7

## Re: PROC REPORT - conditional formatting working for all but one column

thanks a lot

🔒 This topic is solved and locked.