<?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 compute statement / issue with a logic condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652786#M196035</link>
    <description>&lt;P&gt;You don't specify how the results are different.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could it be a matter of numeric precision when performing the calculations?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jun 2020 08:44:38 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2020-06-03T08:44:38Z</dc:date>
    <item>
      <title>proc report compute statement / issue with a logic condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652771#M196025</link>
      <description>&lt;P&gt;Dear community,&lt;/P&gt;
&lt;P&gt;A question as recently been posted:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/New-SAS-User/Proc-Report-compute-if-then/m-p/652591#M22459" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/Proc-Report-compute-if-then/m-p/652591#M22459&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Basically, the idea was to highlight some cells with a specific background color when a condition was true.&lt;/P&gt;
&lt;P&gt;However I can't explain myself why those two syntaxes are not equivalent:&amp;nbsp;the first one works well, but not the other.&lt;/P&gt;
&lt;P&gt;The only difference is that I specified &amp;nbsp;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function keyword"&gt;abs&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_C1_ &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_C2_ &lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt; _C3_&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;/CODE&gt; instead of&amp;nbsp;&lt;CODE class="  language-sas"&gt;_C1_ &lt;SPAN class="token operator-keyword operator"&gt;ne&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_C2_ &lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt; _C3_&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Please find below the code.&amp;nbsp;NB: there are no missing values.&lt;/P&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;
&lt;P&gt;Thanks a lot!&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST;
	input YEAR COL1 COL2 COL3;
	datalines;

2016 30 0 30
2017 20 10 9
2018 5 2 3
2019 10 4 4
2020 15 7 8
2021 5 0 5
;
run;

/* SYNTAX 1 - works well */
title "colour COL2 red if COL1 &amp;lt;&amp;gt; COL2+COL3";
proc report data=WORK.TEST nowd;
	column (YEAR, (COL1 COL2 COL3));
	define YEAR / across;
	define COL1 / analysis SUM missing;
	define COL2 / analysis SUM missing;
	define COL3 / analysis SUM missing;
	compute year;
		if  abs(_C1_ - (_C2_ + _C3_)) &amp;gt; 0 then call define('_c2_','style','style={background=red}');
		if  abs(_C4_ - (_C5_ + _C6_)) &amp;gt; 0 then call define('_c5_','style','style={background=red}');
		if  abs(_C7_ - (_C8_ + _C9_)) &amp;gt; 0 then call define('_c8_','style','style={background=red}');
		if  abs(_C10_ - (_C11_ + _C12_)) &amp;gt; 0 then call define('_c11_','style','style={background=red}');
		if  abs(_C13_ - (_C14_ + _C15_)) &amp;gt; 0 then call define('_c14_','style','style={background=red}');
		if  abs(_C16_ - (_C17_ + _C18_)) &amp;gt; 0 then call define('_c17_','style','style={background=red}');
	endcomp;
run;

/* SYNTAX 2 - issue? */
title "colour COL2 red if COL1 &amp;lt;&amp;gt; COL2+COL3";
proc report data=WORK.TEST nowd;
	column (YEAR, (COL1 COL2 COL3));
	define YEAR / across 'YEAR';
	define COL1 / analysis SUM 'COL1' missing;
	define COL2 / analysis SUM 'COL2' missing;
	define COL3 / analysis SUM 'COL3' missing;
	compute YEAR;

		if  _C1_ ne (_C2_ + _C3_) then call define('_c2_','style','style={background=red}');
		if  _C4_ ne (_C5_ + _C6_) then call define('_c5_','style','style={background=red}');
		if  _C7_ ne (_C8_ + _C9_) then call define('_c8_','style','style={background=red}');
		if  _C10_ ne (_C11_ + _C12_) then call define('_c11_','style','style={background=red}');
		if  _C13_ ne (_C14_ + _C15_) then call define('_c14_','style','style={background=red}');
		if  _C16_ ne (_C17_ + _C18_) then call define('_c17_','style','style={background=red}');

	endcomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jun 2020 07:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652771#M196025</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-03T07:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: proc report compute statement / issue with a logic condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652786#M196035</link>
      <description>&lt;P&gt;You don't specify how the results are different.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could it be a matter of numeric precision when performing the calculations?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 08:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652786#M196035</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-03T08:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc report compute statement / issue with a logic condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652790#M196038</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the results when you run the code:&lt;/P&gt;
&lt;P&gt;-&amp;gt; like the first display, the "second column" of each year should be highlighted when the sum of this column and the third one are not equal to the first one:&lt;/P&gt;
&lt;P&gt;e.g. 2016 : 30 = 0 + 30 so no highlight&lt;/P&gt;
&lt;P&gt;e.g. 2017 : 20 ≠ 10 + 9 so 10 is highlighted&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2020-06-03 à 10.57.20.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40312iDA7658A5345C3CE4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture d’écran 2020-06-03 à 10.57.20.png" alt="Capture d’écran 2020-06-03 à 10.57.20.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 09:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652790#M196038</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-03T09:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc report compute statement / issue with a logic condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652819#M196060</link>
      <description>compute YEAR;&lt;BR /&gt;----&amp;gt;&lt;BR /&gt;compute col3;</description>
      <pubDate>Wed, 03 Jun 2020 11:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652819#M196060</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-06-03T11:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc report compute statement / issue with a logic condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652831#M196064</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;That works great +++&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 11:45:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-compute-statement-issue-with-a-logic-condition/m-p/652831#M196064</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-03T11:45:12Z</dc:date>
    </item>
  </channel>
</rss>

