Hello
I need to apply different colours to the background of a variable, based on the value, in a Proc Report.
I have recreated an example using sashelp:
proc report data=sashelp.demographics nowd;
column region (name, (Pop PopAGR));
define name / across 'name' ORDER=DATA;
define Pop / analysis SUM 'Pop' missing;
define PopAGR / analysis SUM 'PopAGR' missing;
define region / group 'region' missing;
quit;
I need to, say, highlight "PopAGR" in red if it's > 3.00%
I know "if call define" does not work as I am using the variable as "analysis".
I've also tried Proc Format, but I cannot make it work.
I've looked everywhere but can't find a solution!
Thanks in advance
I am using EG 7.13
I suspect that you may have used the wrong value for your format. It may help to show what you tried that "didn't work" as we can explain why not. For example the actual value of 3% is 0.03. So that would be the value to use in a format range.
Proc format library=work; value threepct .03 - high ='red' other ; proc report data=sashelp.demographics nowd; column region (name, (Pop PopAGR)); define name / across 'name' ORDER=DATA; define Pop / analysis SUM 'Pop' missing; define PopAGR / analysis SUM 'PopAGR' missing style=[background=threepct.]; define region / group 'region' missing; quit;
Lots of examples here:
https://www.lexjansen.com/wuss/2006/tutorials/TUT-Carpenter.pdf
I suspect that you may have used the wrong value for your format. It may help to show what you tried that "didn't work" as we can explain why not. For example the actual value of 3% is 0.03. So that would be the value to use in a format range.
Proc format library=work; value threepct .03 - high ='red' other ; proc report data=sashelp.demographics nowd; column region (name, (Pop PopAGR)); define name / across 'name' ORDER=DATA; define Pop / analysis SUM 'Pop' missing; define PopAGR / analysis SUM 'PopAGR' missing style=[background=threepct.]; define region / group 'region' missing; quit;
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.