<?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: Proc Report - How to color code certain cell or column? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808606#M318846</link>
    <description>&lt;P&gt;Two possible causes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NAME IN (‘Ann’,’Ian’) &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;get rid of the curly quotes, make sure you are using straight quotes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, your logic is flawed, the code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if INIT_DATE =. AND NAME IN (‘Ann’,’Ian’)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;never executes. Why? Because first you test to see if INIT_DATE=. and the logic never gets to the &lt;FONT face="courier new,courier"&gt;else if&lt;/FONT&gt;&amp;nbsp;part of the code for the three rows shown in your desired output.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Apr 2022 16:08:22 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-04-19T16:08:22Z</dc:date>
    <item>
      <title>Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808600#M318842</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need assistance on how to color code specific cells using PROC REPORT. I'm trying to resolve my code below as the logic is not reading a certain text variable&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;NAME IN (‘Ann’,’Ian’). &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;Please assist.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc report data=TEST nowd;
TITLE1 j=left "Sample Report
		column ID  ICT_DT  POST_RISK_LEVEL;
		define INIT_DATE/display;
		define NAME/display;
		
compute ICT_DT; 
            if INIT_DATE=. then call define(_col_,"style","style={background=RED}");
			else
			&lt;STRONG&gt;if INIT_DATE =. AND &lt;FONT color="#FF0000"&gt;NAME IN (‘Ann’,’Ian’)&lt;/FONT&gt; then call define(_col_,"style","style={background=WHITE}"); /*NOT WORKING*/&lt;/STRONG&gt;
			endcomp;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 469px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70596iD7544B46C50A8D03/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 15:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808600#M318842</guid>
      <dc:creator>annaleticia</dc:creator>
      <dc:date>2022-04-19T15:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808606#M318846</link>
      <description>&lt;P&gt;Two possible causes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NAME IN (‘Ann’,’Ian’) &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;get rid of the curly quotes, make sure you are using straight quotes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, your logic is flawed, the code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else if INIT_DATE =. AND NAME IN (‘Ann’,’Ian’)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;never executes. Why? Because first you test to see if INIT_DATE=. and the logic never gets to the &lt;FONT face="courier new,courier"&gt;else if&lt;/FONT&gt;&amp;nbsp;part of the code for the three rows shown in your desired output.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 16:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808606#M318846</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-19T16:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808614#M318848</link>
      <description>Hi:&lt;BR /&gt;  In addition to the above suggestions, I am not sure that your code produces the results you show. You do NOT have NAME in the COLUMN statement. Typically, PROC REPORT works from Left to right in setting the style. You show 4 variables in your current COLUMN statement, but you only show 3 columns in your screen shot of the output. We need to see ALL of your code, not just parts of the code. ALL the DEFINE statements, the entire COLUMN statement and ALL of the compute blocks.&lt;BR /&gt;Cynthia</description>
      <pubDate>Tue, 19 Apr 2022 16:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808614#M318848</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2022-04-19T16:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808627#M318850</link>
      <description>Hello, Here's the updated code --- the syntax still not reading the NAME column. proc report data=TEST nowd; TITLE1 j=left "Sample Report column ID INIT_DATE NAME ; define INIT_DATE/display; define NAME/display; compute INIT_DATE; if INIT_DATE =. AND NAME IN ("Ann","Ian") then call define(_col_,"style","style={background=WHITE}"); /*NOT WORKING*/ else if INIT_DATE=. AND NAME IN ("Tom") then call define(_col_,"style","style={background=RED}"); /*NOT WORKING*/ endcomp; run;</description>
      <pubDate>Tue, 19 Apr 2022 17:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808627#M318850</guid>
      <dc:creator>annaleticia</dc:creator>
      <dc:date>2022-04-19T17:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808628#M318851</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Here's the updated code --- the syntax still not reading the NAME column.&lt;BR /&gt;&lt;BR /&gt;proc report data=TEST nowd;&lt;BR /&gt;TITLE1 j=left "Sample Report&lt;BR /&gt;column ID INIT_DATE NAME ;&lt;BR /&gt;define INIT_DATE/display;&lt;BR /&gt;define NAME/display;&lt;BR /&gt;&lt;BR /&gt;compute INIT_DATE;&lt;BR /&gt;if INIT_DATE =. AND NAME IN ("Ann","Ian") then call define(_col_,"style","style={background=WHITE}"); /*NOT WORKING*/&lt;BR /&gt;else if INIT_DATE=. AND NAME IN ("Tom") then call define(_col_,"style","style={background=RED}"); /*NOT WORKING*/&lt;BR /&gt;endcomp;&lt;BR /&gt;run;</description>
      <pubDate>Tue, 19 Apr 2022 17:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808628#M318851</guid>
      <dc:creator>annaleticia</dc:creator>
      <dc:date>2022-04-19T17:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808634#M318852</link>
      <description>&lt;P&gt;Please paste your code into the code window from now on. The code window appears when you click on the "little running man" icon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would help yourself, and help us help you, by properly indenting your code as well, as I show below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Give this a try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=test nowd;
    title1 j=left "Sample Report";
    column id init_date name _dummy;
    define init_date/display;
    define name/display;
    define _dummy/noprint;

    compute _dummy;
        if init_date =. and name in ("Ann","Ian") then call define('init_date',"style","style={background=WHITE}"); 
        else if init_date=. and name in ("Tom") then call define('init_date',"style","style={background=RED}"); 
    endcompute;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32"&gt;@BrunoMueller&lt;/a&gt;&amp;nbsp;for the idea to use _DUMMY to help with coloring columns (see:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Alternate-column-coloring-using-proc-report/m-p/790639#M253161" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Alternate-column-coloring-using-proc-report/m-p/790639#M253161&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 17:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808634#M318852</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-19T17:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808644#M318857</link>
      <description>&lt;P&gt;Also, you should use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;name in ("Anna","Ian")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;instead of&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;name in ("Ann","Ian")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pay attention to details like that.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 18:09:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808644#M318857</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-19T18:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808654#M318859</link>
      <description>Hello,&lt;BR /&gt;For some reason, the program is still not reading the color coding for the name variable.&lt;BR /&gt;*name in ("Ann","Ian")</description>
      <pubDate>Tue, 19 Apr 2022 18:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808654#M318859</guid>
      <dc:creator>annaleticia</dc:creator>
      <dc:date>2022-04-19T18:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808656#M318861</link>
      <description>&lt;P&gt;Are there errors in the log? If so, show us the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not, show us the code you used.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 18:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808656#M318861</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-19T18:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808658#M318862</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Again, you cannot test for NAME in the COMPUTE block for INIT_DATE because of the PROC REPORT "left-to-right" rule. As shown in this output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1650393951035.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70606iB4077F9A6B83BD11/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1650393951035.png" alt="Cynthia_sas_0-1650393951035.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;My report #1 was generated with some fake data and a version of your code with NAME appearing AFTER INIT_DATE in the COLUMN statement. This will not work. However, in my report #2, I used the _DUMMY helper variable technique that was suggested. This is a timing issue based on the left-to-right rule. In your code at the point in time when INIT_DATE is being placed on the report row, the COMPUTE block doesn't know what the value for NAME is because NAME is not yet visible on the report row. PROC REPORT handles each COMPUTE block as the variable is placed on the report row. So when INIT_DATE is being placed and the COMPUTE block is being executed, PROC REPORT does not have any value for NAME yet. Remember the COMPUTE block is building the report row, line by line, column by column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; In my #2 report, I did some additional highlighting with different colors so you could see the way that each variable on the report row can be touched in a different COMPUTE block.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's my code:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_1-1650394182751.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70607i3B7DC78BF588F7D0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_1-1650394182751.png" alt="Cynthia_sas_1-1650394182751.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;There have been many previous forum postings about PROC REPORT and the left-to-right rule. I'd recommend looking at some of those previous postings.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 18:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808658#M318862</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2022-04-19T18:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report - How to color code certain cell or column?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808663#M318865</link>
      <description>Thank you Cynthia!</description>
      <pubDate>Tue, 19 Apr 2022 19:12:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-How-to-color-code-certain-cell-or-column/m-p/808663#M318865</guid>
      <dc:creator>annaleticia</dc:creator>
      <dc:date>2022-04-19T19:12:22Z</dc:date>
    </item>
  </channel>
</rss>

