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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2443 views
  • 2 likes
  • 2 in conversation