<?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: Traffic lighting in proc report not as expected in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940335#M369096</link>
    <description>&lt;P&gt;Thank you! I changed the test code a bit to account for other scenarios and using "in" instead of "ne" to spell out the inclusive responses instead, and ran into a similar issue, even when using both variables as DISPLAY:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input patient_id $ test_date :mmddyy10. test_result $15.;
   format test_date mmddyy10.;
   datalines;
1 . Not Done
2 . Positive
3 09/25/2023 .
4 07/13/2023 Positive
;
run;

proc report data=test;
define test_date / Display "Test Date";
define test_result / Display "Test Result";

compute test_date;
  if test_date = . and test_result in ('Positive' 'Negative' '')
  then call define(_col_,'style','style={background=red}');
endcomp;

compute test_result;
  if (test_result in ('Positive' 'Negative' '') and test_date = .)
  	or (test_result in ('Not Done' '') and test_date ne .)
  then call define(_col_,'style','style={background=red}');
endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas-ss.PNG" style="width: 253px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99535iB4B93E0776C56187/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sas-ss.PNG" alt="sas-ss.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Patient 1: Test Date cell should not be red&lt;/P&gt;
&lt;P&gt;Patient 2: Test Result cell should not be red&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2024 15:59:55 GMT</pubDate>
    <dc:creator>vegan_renegade</dc:creator>
    <dc:date>2024-08-21T15:59:55Z</dc:date>
    <item>
      <title>Traffic lighting in proc report not as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940175#M369062</link>
      <description>&lt;P&gt;HI all, not sure where I have gone wrong with this. I have an actual code, but created this dummy code, and the same issue occurs.&amp;nbsp; Note that I'm asking cells to be red if the test date is missing (.) AND test result is not blank. However, I'm getting red cells in patients 1, 2 even though they have a test date. Based on this code, I should only have a red cell at test result for patient 5. What am I missing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input patient_id $ test_date :mmddyy10. test_result $15.;
   format test_date mmddyy10.;
   datalines;
1 06/01/2023 Negative
2 07/13/2023 Positive
3 09/25/2023 .
4 11/21/2023 .
5 . Positive
;
run;


proc report data=test;
compute test_result;
  if test_date = . and test_result ne ''
  then call define(_col_,'style','style={background=red}');
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sastable.PNG" style="width: 264px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99489iA9ECFAE4F17AB5E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sastable.PNG" alt="sastable.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 23:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940175#M369062</guid>
      <dc:creator>vegan_renegade</dc:creator>
      <dc:date>2024-08-20T23:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Traffic lighting in proc report not as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940179#M369065</link>
      <description>&lt;P&gt;If you want to reference TEST_DATE in the compute block code you need to either DEFINE TEST_DATE as DISPLAY instead of the default of SUM.&amp;nbsp; Or reference it as TEST_DATE.SUM (or some other statistic).&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 00:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940179#M369065</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-21T00:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Traffic lighting in proc report not as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940335#M369096</link>
      <description>&lt;P&gt;Thank you! I changed the test code a bit to account for other scenarios and using "in" instead of "ne" to spell out the inclusive responses instead, and ran into a similar issue, even when using both variables as DISPLAY:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input patient_id $ test_date :mmddyy10. test_result $15.;
   format test_date mmddyy10.;
   datalines;
1 . Not Done
2 . Positive
3 09/25/2023 .
4 07/13/2023 Positive
;
run;

proc report data=test;
define test_date / Display "Test Date";
define test_result / Display "Test Result";

compute test_date;
  if test_date = . and test_result in ('Positive' 'Negative' '')
  then call define(_col_,'style','style={background=red}');
endcomp;

compute test_result;
  if (test_result in ('Positive' 'Negative' '') and test_date = .)
  	or (test_result in ('Not Done' '') and test_date ne .)
  then call define(_col_,'style','style={background=red}');
endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas-ss.PNG" style="width: 253px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99535iB4B93E0776C56187/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sas-ss.PNG" alt="sas-ss.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Patient 1: Test Date cell should not be red&lt;/P&gt;
&lt;P&gt;Patient 2: Test Result cell should not be red&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 15:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940335#M369096</guid>
      <dc:creator>vegan_renegade</dc:creator>
      <dc:date>2024-08-21T15:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Traffic lighting in proc report not as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940343#M369098</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301219"&gt;@vegan_renegade&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you! I changed the test code a bit to account for other scenarios and using "in" instead of "ne" to spell out the inclusive responses instead, and ran into a similar issue, even when using both variables as DISPLAY:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input patient_id $ test_date :mmddyy10. test_result $15.;
   format test_date mmddyy10.;
   datalines;
1 . Not Done
2 . Positive
3 09/25/2023 .
4 07/13/2023 Positive
;
run;

proc report data=test;
define test_date / Display "Test Date";
define test_result / Display "Test Result";

compute test_date;
  if test_date = . and test_result in ('Positive' 'Negative' '')
  then call define(_col_,'style','style={background=red}');
endcomp;

compute test_result;
  if (test_result in ('Positive' 'Negative' '') and test_date = .)
  	or (test_result in ('Not Done' '') and test_date ne .)
  then call define(_col_,'style','style={background=red}');
endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas-ss.PNG" style="width: 253px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99535iB4B93E0776C56187/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sas-ss.PNG" alt="sas-ss.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Patient 1: Test Date cell should not be red&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5" color="#800080"&gt;&lt;STRONG&gt;Patient 2: Test Result cell should not be red&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why shouldn't Patient 2 result be red? The code says if the values is Positive and test_date is missing which are both the case for Patient 2.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 16:44:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940343#M369098</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-21T16:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Traffic lighting in proc report not as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940347#M369100</link>
      <description>&lt;P&gt;You are asking the COMPUTE block to look into the future.&amp;nbsp; And since SAS has not yet released their psychic features that cannot work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=test;
  column patient_id test_result test_date test_result=tr2 ;
define test_date / Display "Test Date";
define test_result / noprint ;
define tr2 / Display "Test Result";

compute test_date;
  if test_date = . and test_result in ('Positive' 'Negative' '')
  then call define(_col_,'style','style={background=red}');
endcomp;

compute tr2;
   if (test_result in ('Positive' 'Negative') and missing(test_date))
   or (test_result in ('Not Done' ' ') and not missing(test_date))
  then call define(_col_,'style','style={background=red}');
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1724259637026.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99537i46A39112631C6627/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1724259637026.png" alt="Tom_0-1724259637026.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 17:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940347#M369100</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-21T17:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Traffic lighting in proc report not as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940349#M369102</link>
      <description>There is no need for an unhelpful and condescending response.</description>
      <pubDate>Wed, 21 Aug 2024 17:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940349#M369102</guid>
      <dc:creator>vegan_renegade</dc:creator>
      <dc:date>2024-08-21T17:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Traffic lighting in proc report not as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940351#M369103</link>
      <description>Haha you're right. I guess I'm left with the issue on Patient # 1 only. Any clue on that one?</description>
      <pubDate>Wed, 21 Aug 2024 17:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940351#M369103</guid>
      <dc:creator>vegan_renegade</dc:creator>
      <dc:date>2024-08-21T17:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Traffic lighting in proc report not as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940354#M369105</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301219"&gt;@vegan_renegade&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;There is no need for an unhelpful and condescending response.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Huh?&lt;/P&gt;
&lt;P&gt;Did you try making sure that TEST_RESULT appears in the COLUMN statement BEFORE the variable where you are trying to use its value in the COMPUTE block?&amp;nbsp; Or not?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 17:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940354#M369105</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-21T17:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Traffic lighting in proc report not as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940356#M369106</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301219"&gt;@vegan_renegade&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;There is no need for an unhelpful and condescending response.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Perhaps not, but there a details on how Proc Report uses things. For example from &lt;A href="http://support.sas.com/resources/papers/proceedings15/SAS1642-2015.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings15/SAS1642-2015.pdf&lt;/A&gt; which is referenced in my version of the online help for Proc Report under the Concepts tab in the Using Compute Blocks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;LESSON 1: THE COMPUTE STATEMENT &lt;BR /&gt;PROC REPORT processes a data set by reading the variables in the order in which they appear &lt;STRONG&gt;from left &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;to right&lt;/STRONG&gt; in the COLUMN statement. The procedure builds the report one column and one row at a time, &lt;BR /&gt;and COMPUTE statements are executed as the report is built.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I emphasized the left to right because that is the order things work. A compute block cannot use a column to the right of its position. If you want Test_date to use Test_result directly it has to be to the right of Test_result. Since you have not provided a COLUMNS statement, then the order is the default from the data set and Test_date is LEFT of test_result. So doesn't "see" the Test_result values.&lt;/P&gt;
&lt;P&gt;By creating the Alias for Test_date on a Columns statement that is to the right of Test_result you get around that limitation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While not required a Columns statement is a good idea just so you keep in mind the relative positions of the output. Also at some time you have someone provide a similar data but the variables in different order. It might take way more time than it should to realize your output is different because of the missing columns statement.&lt;/P&gt;
&lt;P&gt;Similarly, the Define statement to reinforce if a variable is display, group/order, analysis makes a difference and worth including.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 17:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Traffic-lighting-in-proc-report-not-as-expected/m-p/940356#M369106</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-21T17:55:48Z</dc:date>
    </item>
  </channel>
</rss>

