BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sturg1dj
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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.

View solution in original post

2 REPLIES 2
Reeza
Super User

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 2695 views
  • 2 likes
  • 2 in conversation