DATA Step, Macro, Functions and more

PROC Report CELL Coloring condition

Reply
Frequent Contributor
Posts: 78

PROC Report CELL Coloring condition

Could somebody point out please what I am doing wrong...

 

I have program as below with all variables(test1-test4) numeric however still Compute condition doesn't seems to work.So my intention was basically based on comparison between Test1 and test4 variable set the color of the cell different ...

 

 

 PROC REPORT DATA=BREACHES NOWD HEADLINE  ;
 column test1 test2 test3 test4;
 define test1 /display ;
 define test2 /display ;
 define test3 /display ;
 define test4 /display ;

COMPUTE test1;                                            
IF  test1  >  test4 THEN DO;                              
CALL DEFINE(_COL_,'STYLE','STYLE={BACKGROUNDCOLOR=RED}');    
                           END;                              
ENDCOMP;       

Super User
Super User
Posts: 7,392

Re: PROC Report CELL Coloring condition

What you are describing is traffic lighting, for which there are many documents out there on the subject:

http://www2.sas.com/proceedings/sugi31/142-31.pdf

Is result one from Google, and it shows how to do it.

Frequent Contributor
Posts: 78

Re: PROC Report CELL Coloring condition

I have looked at the traffic lighting example however unless I hard code value of TEST4 the COMPUTE TEST1 do not bring the desired output.
Super Contributor
Posts: 394

Re: PROC Report CELL Coloring condition

PROC REPORT processes the columns in the report from left to right. When it processes TEST1 the value of TEST4 is unknown. Create an alias of TEST4 to create a dummy column to the left of TEST1. Refer to the alias instead of TEST4 in your COMPUTE block. Use the NOPRINT option on the dummy column to keep it from appearing in your report. 

 

Check out the Compute Block Processing section in the PROC REPORT doc. Also there are many fine papers on PROC REPORT on http://support.sas.com.

Frequent Contributor
Posts: 78

Re: PROC Report CELL Coloring condition

Thanks Tim this worked....I even not had to define alias moving the variable in the column definition worked...

Ask a Question
Discussion stats
  • 4 replies
  • 197 views
  • 0 likes
  • 3 in conversation