<?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: Why SAS think -90 is not -90 from some algorithms? in SAS Customer Intelligence</title>
    <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977815#M2093</link>
    <description>Thank you!&lt;BR /&gt;</description>
    <pubDate>Sat, 25 Oct 2025 04:58:57 GMT</pubDate>
    <dc:creator>karenyang</dc:creator>
    <dc:date>2025-10-25T04:58:57Z</dc:date>
    <item>
      <title>Why SAS think -90 is not -90 from some algorithms?</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977685#M2088</link>
      <description>&lt;DIV&gt;data three;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;x=36; y=3.6;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;z=(y-x)/x*100;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if z&amp;lt;=-90 then a=1;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else a=0;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;if a=-90 then flag=1;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;proc print;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I got the following result:&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV align="center"&gt;Obs x y z a flag1 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;36&lt;/TD&gt;&lt;TD&gt;3.6&lt;/TD&gt;&lt;TD&gt;-90&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I expect a=1, flag=1. But I got zero, null value instead. Why?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Oct 2025 21:46:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977685#M2088</guid>
      <dc:creator>karenyang</dc:creator>
      <dc:date>2025-10-23T21:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why SAS think -90 is not -90 from some algorithms?</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977686#M2089</link>
      <description>&lt;P&gt;How&amp;nbsp; can I make SAS think it is -90?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2025 22:04:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977686#M2089</guid>
      <dc:creator>karenyang</dc:creator>
      <dc:date>2025-10-23T22:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why SAS think -90 is not -90 from some algorithms</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977687#M2090</link>
      <description>It's a datatype thing.&lt;BR /&gt;&lt;BR /&gt;Try:&lt;BR /&gt;&lt;BR /&gt;if int(z)&amp;lt;=-90 then a=1;&lt;BR /&gt;&lt;BR /&gt;And your flag is always missing as you check for a being &amp;lt;=90.  A can only be 1 or 0&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Oct 2025 22:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977687#M2090</guid>
      <dc:creator>OlafKratzsch</dc:creator>
      <dc:date>2025-10-23T22:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why SAS think -90 is not -90 from some algorithms?</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977693#M2091</link>
      <description>&lt;P&gt;It has probably something to do with numeric values in the SAS System being represented as IEEE double-precision floating-point numbers.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_061/lepg/p0dv87zb3bnse6n1mqo360be70qr.htm" target="_blank" rel="noopener"&gt;SAS Help Center: Numeric Precision&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
file print;
x=36; y=3.6;
z=(y-x)/x*100; put z= 25.15;
if z=-90        then do; put '1. hurray ; z equals -90'; end;
if int(z)=-90   then do; put '2. hurray ; z equals -90'; end;
if floor(z)=-90 then do; put '3. hurray ; z equals -90'; end;
if ceil(z)=-90  then do; put '4. hurray ; z equals -90'; end;
if round(z)=-90 then do; put '5. hurray ; z equals -90'; end;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Ciao,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2025 23:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977693#M2091</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2025-10-23T23:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why SAS think -90 is not -90 from some algorithms?</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977705#M2092</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60547"&gt;@sbxkoenk&lt;/a&gt;&amp;nbsp;is correct, this is a numerical precision issue. Here is more reading:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/comparing-two-values/m-p/761113#M240787" target="_blank" rel="noopener"&gt;Solved: comparing two values - SAS Support Communities&lt;/A&gt;&amp;nbsp;and even more at&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Formula-evaluates-totals-the-same-set-of-variables-differently/m-p/761364#M240925" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Formula-evaluates-totals-the-same-set-of-variables-differently/m-p/761364#M240925&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your value of Z is not -90 because SAS cannot represent some decimals exactly. Decimal values that are not an integer power of 2 cannot be represented exactly. So y=3.6 produces a number that isn't quite 3.6 (can't represent it exactly) and so the value of Z (which uses Y) isn't exactly -90.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you display the numbers using the HEX format so we can see the exact value, like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data three;
    x=36; y=3.6;
    z=(y-x)/x*100;
    minusninety=-90;
    if z&amp;lt;=-90 then a=1; else a=0;
    if a=-90 then flag=1;
run;

proc print data=three;
    var x y z minusninety;
    format x y z minusninety hex16.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is the result, note that variable Z is not exactly equal to the value of variable MINUSNINETY. So then variable A=0 because it is not exactly equal.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs                   x                   y                   z         minusninety

 1     4042000000000000    400CCCCCCCCCCCCD    C0567FFFFFFFFFFF    C056800000000000

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then flag is missing because it only is assigned a value when A=1, but A=0 so no value is assigned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the best solution is to use the ROUND function like this:&amp;nbsp;&lt;FONT face="courier new,courier"&gt;if round(z)=-90&lt;/FONT&gt;&amp;nbsp;as suggest by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/comparing-two-values/m-p/761115#M240788" target="_self"&gt;here&lt;/A&gt; is a better solution which will work in more cases than the INT or FLOOR or CEIL function. In this case INT works but there may be other cases where you are not comparing to an integer, and so INT won't work in those cases but ROUND will.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Oct 2025 11:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977705#M2092</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-10-24T11:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why SAS think -90 is not -90 from some algorithms?</title>
      <link>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977815#M2093</link>
      <description>Thank you!&lt;BR /&gt;</description>
      <pubDate>Sat, 25 Oct 2025 04:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Customer-Intelligence/Why-SAS-think-90-is-not-90-from-some-algorithms/m-p/977815#M2093</guid>
      <dc:creator>karenyang</dc:creator>
      <dc:date>2025-10-25T04:58:57Z</dc:date>
    </item>
  </channel>
</rss>

