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;
In the COLUMN statement, FLAG_X must appear before (to the left of) X_RATE.
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.
cynthia
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.