BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MART1
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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;

View solution in original post

4 REPLIES 4
MART1
Quartz | Level 8
thanks PaigeMiller

I didn't come across this article when I was looking

thanks
ballardw
Super User

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;
MART1
Quartz | Level 8
that's great many thanks ballardw

I was not applying the "style" syntax correctly

thanks

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!
Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 716 views
  • 0 likes
  • 3 in conversation