I have a report where I set the colors of the header by certain groupings. I just added total to the report using RBREAK AFTER /SUMMARIZE and I would like to color the summary row to match the corresponding header. I know I need to use the compute statement, but I can't figure out how to set the color by the column the data is in rather than by the value of the data. Any ideas? Thanks!
define tot/ analysis format=comma12. 'Total' style(header) = [background = midnightblue foreground = white] ; |
define Change/ analysis format=comma12. 'Total Changed' style(header) = [background = midnightblue foreground = white] ; |
define Per_Change/ computed format=percent8.2 '% of Changed' style(header) = [background = midnightblue foreground = white] ;
define Impact/ analysis format=comma12. 'Count of Changed' style(header) = [background = MediumBlue foreground = white]; | |
define NoImpact/ analysis format=comma12. 'Count of Changed' style(header) = [background = RoyalBlue foreground = white] ; | |
define Per_Impact/ computed format=percent8.2 '% of Changed' style(header) = [background = MediumBlue foreground = white]; | |
define Per_NoImpact/ computed format=percent8.2 '% of Changed' style(header) = [background = RoyalBlue foreground = white]]; |
Hi:
The answer will depend on whether you have ACROSS usage items or not. This is hard to tell, since you don't show all of your PROC REPORT code and you don't show your ODS statements. And, you don't show your COMPUTE blocks for the COMPUTED variables.
But, you can make the change you want in a CALL DEFINE statement. And since PROC REPORT allows you to test an automatic variable called _BREAK_, you can easily issue your CALL DEFINE based on the summary line having a value of '_RBREAK_' for the summary line.
Some example code below. Not using any ACROSS items (which would cause you to need slightly different code.
cynthia
ods html file='c:\temp\showcolors.html'
style=sasweb;
proc report data=sashelp.class nowd
style(summary)=Header;
column name age height weight sex xxx;
define name / order;
define age / min 'Age'
style(header)={background=pink};
define height / mean 'Ht'
style(header)={background=lightbrown};
define xxx / computed
style(header)={background=lightgreen};
compute xxx;
xxx= height.mean * age.min;
if _break_ = '_RBREAK_' then do;
call define (_col_,'style','style={background=lightgreen}');
end;
endcomp;
rbreak after / summarize;
compute age;
if _break_ = '_RBREAK_' then do;
call define (_col_,'style','style={background=pink}');
end;
endcomp;
compute height;
if _break_ = '_RBREAK_' then do;
call define (_col_,'style','style={background=lightbrown}');
end;
endcomp;
run;
ods html close;
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.