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
Diamond | Level 26

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1277 views
  • 0 likes
  • 3 in conversation