<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Conditional formatting in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-formatting/m-p/6529#M2553</link>
    <description>Hi:&lt;BR /&gt;
  There are 2 ways to do what you want to do:&lt;BR /&gt;
1) Use a user-defined format with the STYLE= option to change the background color of the cell&lt;BR /&gt;
[pre]&lt;BR /&gt;
  define myvar / sum&lt;BR /&gt;
            style(column)={background=bfmt.};&lt;BR /&gt;
[/pre]&lt;BR /&gt;
where the BFMT format listed the colors to be used for various values:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value BFMT 0-.6 = 'red'&lt;BR /&gt;
            .6-.9 = 'yellow'&lt;BR /&gt;
            .91-1.00 = 'green';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
OR&lt;BR /&gt;
2) you could use a CALL DEFINE statement in a COMPUTE block.&lt;BR /&gt;
  [pre]&lt;BR /&gt;
COMPUTE MYVAR;&lt;BR /&gt;
   IF ....&lt;BR /&gt;
      call define (_COL_,'style',&lt;BR /&gt;
                      'style={background=green}');&lt;BR /&gt;
  ELSE IF ...&lt;BR /&gt;
      call define (_COL_,'style',&lt;BR /&gt;
                      'style={background=yellow}');&lt;BR /&gt;
ENDCOMP:&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
The advantage of the user-defined format is that if you only want to change the background color of a cell based on the value in the cell, this is an easy way to implement the change. On the other hand, if you needed to use more complex logic, like check the value of 2 variables in order to do the traffic lighting, then call define is the only way to implement that kind of traffic lighting:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  if region = 'Asia' and someother = 1 then&lt;BR /&gt;
     call define ....;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
This paper has some examples:&lt;BR /&gt;
&lt;A href="http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf" target="_blank"&gt;http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf&lt;/A&gt; &lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/23/353.html" target="_blank"&gt;http://support.sas.com/kb/23/353.html&lt;/A&gt; (this shows both approaches and although it discusses ODS HTML, the techniques also work for RTF and PDF)&lt;BR /&gt;
&lt;BR /&gt;
You may find other examples on the Tech Support site at &lt;A href="http://support.sas.com" target="_blank"&gt;http://support.sas.com&lt;/A&gt;. There are also examples in the PROC REPORT documentation. Or, once you decide on your technique after consulting various resources, you can also contact Tech Support for more help.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
    <pubDate>Thu, 24 Jan 2008 17:57:45 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2008-01-24T17:57:45Z</dc:date>
    <item>
      <title>Conditional formatting</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-formatting/m-p/6528#M2552</link>
      <description>Hello all.. &lt;BR /&gt;
&lt;BR /&gt;
Is there a way, in ODS via Proc Report, to conditionally format the background color for a cell depending on the value for that cell?   For example, 0-60%-red  6t0-90% yellow,  91-100% green?  Any advice most appreciated.</description>
      <pubDate>Thu, 24 Jan 2008 17:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-formatting/m-p/6528#M2552</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-24T17:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional formatting</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-formatting/m-p/6529#M2553</link>
      <description>Hi:&lt;BR /&gt;
  There are 2 ways to do what you want to do:&lt;BR /&gt;
1) Use a user-defined format with the STYLE= option to change the background color of the cell&lt;BR /&gt;
[pre]&lt;BR /&gt;
  define myvar / sum&lt;BR /&gt;
            style(column)={background=bfmt.};&lt;BR /&gt;
[/pre]&lt;BR /&gt;
where the BFMT format listed the colors to be used for various values:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value BFMT 0-.6 = 'red'&lt;BR /&gt;
            .6-.9 = 'yellow'&lt;BR /&gt;
            .91-1.00 = 'green';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
OR&lt;BR /&gt;
2) you could use a CALL DEFINE statement in a COMPUTE block.&lt;BR /&gt;
  [pre]&lt;BR /&gt;
COMPUTE MYVAR;&lt;BR /&gt;
   IF ....&lt;BR /&gt;
      call define (_COL_,'style',&lt;BR /&gt;
                      'style={background=green}');&lt;BR /&gt;
  ELSE IF ...&lt;BR /&gt;
      call define (_COL_,'style',&lt;BR /&gt;
                      'style={background=yellow}');&lt;BR /&gt;
ENDCOMP:&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
The advantage of the user-defined format is that if you only want to change the background color of a cell based on the value in the cell, this is an easy way to implement the change. On the other hand, if you needed to use more complex logic, like check the value of 2 variables in order to do the traffic lighting, then call define is the only way to implement that kind of traffic lighting:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  if region = 'Asia' and someother = 1 then&lt;BR /&gt;
     call define ....;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
This paper has some examples:&lt;BR /&gt;
&lt;A href="http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf" target="_blank"&gt;http://support.sas.com/rnd/papers/sgf07/sgf2007-report.pdf&lt;/A&gt; &lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/23/353.html" target="_blank"&gt;http://support.sas.com/kb/23/353.html&lt;/A&gt; (this shows both approaches and although it discusses ODS HTML, the techniques also work for RTF and PDF)&lt;BR /&gt;
&lt;BR /&gt;
You may find other examples on the Tech Support site at &lt;A href="http://support.sas.com" target="_blank"&gt;http://support.sas.com&lt;/A&gt;. There are also examples in the PROC REPORT documentation. Or, once you decide on your technique after consulting various resources, you can also contact Tech Support for more help.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 24 Jan 2008 17:57:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-formatting/m-p/6529#M2553</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-01-24T17:57:45Z</dc:date>
    </item>
  </channel>
</rss>

