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-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!

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.

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