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;
Calling @Cynthia_sas
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.