BookmarkSubscribeRSS Feed
srinivaschary
Calcite | Level 5

 

Hi,

    I want to change the color of the header background and foreground for one value of the variables under the across variable (for Fever,cases and rate as one color and same goes with Cold & Flu ). I want to change the color of header cells only not their values and want separate colors for fever, cold and flu. I want different colors for (fever,cases & rates )&(cold,cases & rates) (flu,cases & rates ) cells and  Version 9.3 or 9.4. A sample SAS Proc report code is below.

 

 

data test;
length name $ 10 disease $ 10.;
infile datalines dsd;
input name $ disease cases rate;
datalines;
State,Fever,4847,25.16
State,Cold,25632,131.5
State,Flu,103825,535.82
Lincoln,Fever,3920,44.17
Lincoln,Cold,16913,190.18
Lincoln,Flu,62965,735.39
Washington,Fever,827,56.56
Washington,Cold,3609,234.26
Washington,Flu,16610,1078.8
Kings,Fever,1026,37.45
Kings,Cold,4984,181.85
Kings,Flu,18388,694.33
Sussex,Fever,1411,78.38
Sussex,Cold,5515,300.46
Sussex,Flu,13881,813.11
Queens,Fever,616,26.03
Queens,Cold,2496,107.75
Queens,Flu,12518,558.09
;
run;

 

proc report data=test nowd headline headskip

style(column)={background=gray foreground=black}
style(report)=[rules=rows bordercolor=white];
columns (name disease,(cases rate));
define name/group order=data 'County' style(column)={background=lightgray} style(header)=[bordertopcolor=gainsboro background=gainsboro foreground=black];
define disease/across '' order=data style(header)={background=purple foreground=pink}; ;
define cases/'Cases' format=comma9. ;
define rate/'Rate' format=comma12.1 ;
compute cases;
call define('_c4_','style','style={background=lighttgray}');
call define('_c5_','style','style={background=cyan}');
endcomp;
compute disease;
if disease='Fever' then do;
call define(_col_,'style','style=[background=brown ');
end;
else if disease='Flu' then do;
call define(_col_,'style','style=[background=green ');
end;
else if disease='Cold' then do;
call define(_col_,'style','style=[background=orange ');
end;
endcomp;
run;
quit;

2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
The challenge with your CALL DEFINE is that it does not touch the header cells which is what you say you want to touch. I question whether you want brown as a color, since the black font on a brown background will be nearly illegible.

Are the colors in the XLSX what you want or what you show in your code. It looks like the fonts are a different color in the XLSX example.

What is your desired destination for the PROC REPORT output?

The challenge with your ACROSS items is that there are a couple of different ways you might proceed. I've got one example here: http://support.sas.com/resources/papers/proceedings14/SAS388-2014.pdf on pages 12/13. I know that some folks have used a format example for the ACROSS, but that won't impact the CASE and RATE under each unique ACROSS value, which is what you indicate that you want.

BTW, headline and headskip are ignored by ODS destinations because they are LISTING-only options and irrelevant for ODS destinations like ODS RTF, ODS PDF, ODS HTML, or ODS EXCEL.

To make it easy, I might switch to TABULATE, because a header cell can inherit attributes from the parent cell above or else if you want to stick with REPORT, make 2 passes thru the data.

Cynthia

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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