Hi,
Is it possible to color the class variable using different dynamic rules (traffic light coloring) for each column. I am trying to color VAR2 (class1) using one rule, VAR2 (class3) using another rule...
this code will color the whole table using the same "traffic" format, but I want to have 3 independent traffic rules.
PROC FORMAT;
VALUE TRAFFIC
LOW-<30='RED'
30-50='YELLOW'
50< - HIGH= 'GREEN';
RUN;
PROC TABULATE DATE=INPUT_TABLE;
CLASS VAR1;
CLASS VAR2;
TABLE VAR1, VAR2*[STYLE=[BACKROUND=TRAFFIC.];
RUN;
Thanks,
Proc TABULATE does not allow you to have individual format per CLASS value.
But you could use Proc REPORT where you do have more control over this. The example below shows how to have different formats for different ACROSS values. The names _c2_, _c3_ etc, are the actual column number in the report. The _dummy computed variable is used to apply the different formats to the proper column.
proc format;
value asia
0 - 15000 = "cxFF0080"
15000 - 20000 = "cxC83680"
20000 - high = "cx916D80"
;
value europe
0 - 36000 = "cx00FF80"
36000 - 40000 = "cx00C49D"
40000 - high = "cx009CB0"
;
run;
proc report data=sashelp.cars;
column type origin, invoice _dummy;
define type / group;
define origin / across;
define invoice / analysis mean;
define _dummy / computed noprint;
compute _dummy;
call define("_c2_", "style", "style={background=asia.}");
call define("_c3_", "style", "style={background=europe.}");
call define("_c4_", "style", "style={background=blue}");
endcomp;
run;
Proc TABULATE does not allow you to have individual format per CLASS value.
But you could use Proc REPORT where you do have more control over this. The example below shows how to have different formats for different ACROSS values. The names _c2_, _c3_ etc, are the actual column number in the report. The _dummy computed variable is used to apply the different formats to the proper column.
proc format;
value asia
0 - 15000 = "cxFF0080"
15000 - 20000 = "cxC83680"
20000 - high = "cx916D80"
;
value europe
0 - 36000 = "cx00FF80"
36000 - 40000 = "cx00C49D"
40000 - high = "cx009CB0"
;
run;
proc report data=sashelp.cars;
column type origin, invoice _dummy;
define type / group;
define origin / across;
define invoice / analysis mean;
define _dummy / computed noprint;
compute _dummy;
call define("_c2_", "style", "style={background=asia.}");
call define("_c3_", "style", "style={background=europe.}");
call define("_c4_", "style", "style={background=blue}");
endcomp;
run;
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!
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.
Ready to level-up your skills? Choose your own adventure.