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