BookmarkSubscribeRSS Feed
sw8ishi1
Calcite | Level 5

I am trying to color x-rate based on flag_x value but below code is not working.. please help. sample file attached.


PROC REPORT DATA= FINAL NOWD;
COLUMN HOSPITAL_CODE x_RATE THRESHOLD TARGET MAX FLAG_x;


DEFINE HOSPITAL_CODE / DISPLAY;
DEFINE x_RATE / DISPLAY;
DEFINE THRESHOLD / DISPLAY;
DEFINE TARGET / DISPLAY;
DEFINE MAX / DISPLAY;
DEFINE FLAG_x / DISPLAY;

COMPUTE x_RATE;
IF FLAG_x=1 THEN CALL DEFINE(_COL_,'STYLE','STYLE={BACKGROUND=blue}');
ELSE IF FLAG_x=2 THEN CALL DEFINE(_COL_,'STYLE','STYLE={BACKGROUND=GREEN}');
ELSE IF FLAG_x=3 THEN CALL DEFINE(_COL_,'STYLE','STYLE={BACKGROUND=YELLOW}');
ELSE IF FLAG_x=4 THEN CALL DEFINE(_COL_,'STYLE','STYLE={BACKGROUND=RED}');
ENDCOMP;


RUN;

2 REPLIES 2
PaigeMiller
Diamond | Level 26

In the COLUMN statement, FLAG_X must appear before (to the left of) X_RATE.

--
Paige Miller
Cynthia_sas
SAS Super FREQ

Hi:

  And, if you absolutely need the variable FLAG_X listed as the last item on the report row, then you can use it multiple times on the report. Use it once to the left of X_RATE for highlighting and then use it again with an alias name in the column statement so it will appear in the position you want. In the code below, AGE is used to highlight the SEX column, but it also appears as the last variable on the report row because of using the construction AGE=SHOWLAST in the COLUMN statement to place the alias item at the end of the row.

cynthiause_alias.png

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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