BookmarkSubscribeRSS Feed
rkumar23
Calcite | Level 5

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;       

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

rkumar23
Calcite | Level 5
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.
Tim_SAS
Barite | Level 11

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.

rkumar23
Calcite | Level 5

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

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 1343 views
  • 0 likes
  • 3 in conversation