The SAS Output Delivery System and reporting techniques

Using different color format for different row in ODS.

Reply
N/A
Posts: 0

Using different color format for different row in ODS.

Hi,

I like to use different format depends on the value of the row variable (TESTCODE) in Proc Tabulate.

For example, if TESTCODE = 'ANA', then it should use {STYLE={BACKGROUND=ANA_COL.}}. if TESTCODE = 'DNA', then it should use {STYLE={BACKGROUND=DNA_COL.}}.

Any idea how I can do this??
See the attached code below.

Thank you.
James

-----------------------------------------

PROC FORMAT;
value ANA_COL 0-23 = 'GREEN' 23<-HIGH = 'RED' . = 'WHITE' OTHER = 'BLACK';
value DNAR_COL 0-<7 = 'GREEN' 7-HIGH = 'RED' . = 'WHITE' OTHER = 'BLACK';
value DNA_COL 0-20 = 'GREEN' 20<-HIGH = 'RED' . = 'WHITE' OTHER = 'BLACK';
value ENA_COL 0-<8 = 'GREEN' 8-10 = 'BLUE' 10<-HIGH = 'RED' . = 'WHITE' OTHER = 'BLACK';
RUN;

PROC TABULATE DATA = IN MISSING;
TITLE;
CLASS SUBJID LBDT TESTCODE VISIT_ID;
VAR LBORRESN;
TABLE SUBJID, TESTCODE, LBDT*LBORRESN*{STYLE={BACKGROUND=ANA_COL.}};
RUN;
SAS Employee
Posts: 174

Re: Using different color format for different row in ODS.

What you're wanting to do is not possible. You can't vary formats based on data values.

-- David Kelley, SAS
N/A
Posts: 0

Re: Using different color format for different row in ODS.

Thanks.

Can you think of any other way to do this??

James
SAS Super FREQ
Posts: 8,743

Re: Using different color format for different row in ODS.

David is correct that this is not something that TABULATE does. You might approximate what you want to do with PROC REPORT. In this program, differing formats are applied based on the "row" variable for DIVISION using a CALL DEFINE in a COMPUTE block:[pre]

proc format;
value CON 0-< 50000 = 'yellow'
50000-high = 'pink';
value EDU 0-< 70000 = 'beige'
70000-high = 'cyan';
run;

ods html file='c:\temp\rep_hilite.html'
style=sasweb;

proc report data=sashelp.prdsale nowd;
column country division prodtype,actual;
define country /group noprint;
define division/group;
define prodtype / across;
define actual / sum 'Sales';
compute actual;
if division = 'CONSUMER' then do;
call define('_C3_','STYLE','style={background=CON.}');
call define('_C4_','STYLE','style={background=CON.}');
end;
if division = 'EDUCATION' then do;
call define('_C3_','STYLE','style={background=EDU.}');
call define('_C4_','STYLE','style={background=EDU.}');
end;
endcomp;
by country;
run;
ods html close;
[/pre]
Although there is a bit of brute force programming in that the format is not automatically set, but has to be done inside the CALL DEFINE, this may provide you something close to what you want.

The solution could be adapted to use macro variables, macro do loops or arrays if you have a lot of across variables. I show the "hard-coded" method because I only have 2 across variables.
cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 149 views
  • 0 likes
  • 3 in conversation