<?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: ODS RTF Proc Report:   coloring cells based on position, not values. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ODS-RTF-Proc-Report-coloring-cells-based-on-position-not-values/m-p/837054#M330982</link>
    <description>&lt;P&gt;Maybe not the most elegant but should get you started. Note the ADDED variable ROW.&lt;/P&gt;
&lt;PRE&gt;data Temp1;
input Col1 $4. Var1 Var2 Var3 Var4;
row + 1;
datalines;
Var1 . 45 200 223 11
Var2 0.43 . 43 99
Var3 0.98 0.89 . 39
Var4 0.99 0.77 0.99 .
;
run;

proc report data=Temp1
style(Header)=[backgroundcolor = lightgrey];
columns row Col1 Var1 Var2 Var3 Var4;
   define row /noprint order;
   compute var1;
      if row=2 then 
         call define(3, "style",
                  "style=[backgroundcolor=yellow]");
      if row in (3,4) then 
         call define(3, "style",
                  "style=[backgroundcolor=lightgreen]");

   endcomp;
run;&lt;/PRE&gt;
&lt;P&gt;ROW has the NOPRINT property so it does not appear in the table but values can be checked in a compute block.&lt;/P&gt;
&lt;P&gt;Note that call define is setting the number of the column &lt;STRONG&gt;based on the Columns&lt;/STRONG&gt; &lt;STRONG&gt;statement &lt;/STRONG&gt;definition. So the 3rd column is Var1 after Row and Col1.&lt;/P&gt;
&lt;P&gt;And exercise for the interested student to do the columns for Var2, var3 and var4 as needed.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2022 22:00:37 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-10-05T22:00:37Z</dc:date>
    <item>
      <title>ODS RTF Proc Report:   coloring cells based on position, not values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-RTF-Proc-Report-coloring-cells-based-on-position-not-values/m-p/837038#M330976</link>
      <description>&lt;P&gt;Given a table such as&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Temp1;
input Col1 $4. Var1 Var2 Var3 Var4;
datalines;
Var1 . 45 200 223 11
Var2 0.43 . 43 99
Var3 0.98 0.89 . 39
Var4 0.99 0.77 0.99 .
;
run;

%LET FilePath=
	C:\SamplePath\Folder1;
ODS RTF File="&amp;amp;FilePath.\ColorTest.Rtf";
ODS Escapechar='^';
options nonumber nodate;

proc report data=Temp1
style(Header)=[backgroundcolor = lightgrey];
columns Col1 Var1 Var2 Var3 Var4;
run;
ODS RTF close; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It ouputs the following rtf file, without the colors.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mcook_0-1664999946480.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75931i3BBA3C751A6645DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mcook_0-1664999946480.png" alt="mcook_0-1664999946480.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;is it possible to add colors to certain cells based on the cell position, and not by its value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ie. the cells below the diagonal for var2 x Var1, and Var4 x Var3 should always be yellow, regardless of their values.&amp;nbsp; with the others cells being green.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 20:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-RTF-Proc-Report-coloring-cells-based-on-position-not-values/m-p/837038#M330976</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2022-10-05T20:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report:   coloring cells based on position, not values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-RTF-Proc-Report-coloring-cells-based-on-position-not-values/m-p/837054#M330982</link>
      <description>&lt;P&gt;Maybe not the most elegant but should get you started. Note the ADDED variable ROW.&lt;/P&gt;
&lt;PRE&gt;data Temp1;
input Col1 $4. Var1 Var2 Var3 Var4;
row + 1;
datalines;
Var1 . 45 200 223 11
Var2 0.43 . 43 99
Var3 0.98 0.89 . 39
Var4 0.99 0.77 0.99 .
;
run;

proc report data=Temp1
style(Header)=[backgroundcolor = lightgrey];
columns row Col1 Var1 Var2 Var3 Var4;
   define row /noprint order;
   compute var1;
      if row=2 then 
         call define(3, "style",
                  "style=[backgroundcolor=yellow]");
      if row in (3,4) then 
         call define(3, "style",
                  "style=[backgroundcolor=lightgreen]");

   endcomp;
run;&lt;/PRE&gt;
&lt;P&gt;ROW has the NOPRINT property so it does not appear in the table but values can be checked in a compute block.&lt;/P&gt;
&lt;P&gt;Note that call define is setting the number of the column &lt;STRONG&gt;based on the Columns&lt;/STRONG&gt; &lt;STRONG&gt;statement &lt;/STRONG&gt;definition. So the 3rd column is Var1 after Row and Col1.&lt;/P&gt;
&lt;P&gt;And exercise for the interested student to do the columns for Var2, var3 and var4 as needed.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 22:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-RTF-Proc-Report-coloring-cells-based-on-position-not-values/m-p/837054#M330982</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-05T22:00:37Z</dc:date>
    </item>
  </channel>
</rss>

