<?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: numeric format does not validate intervals properly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934276#M367394</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;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's the default value 1E-12 of the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1upn25lbfo6mkn1wncu4dyh9q91.htm#n0qhedcd1ls7ren1hn86ntotxrai" target="_blank" rel="noopener"&gt;FUZZ= option&lt;/A&gt; which causes this. Use FUZZ=0 (or, e.g., FUZZ=1E-23 in this example) to avoid the unwanted formatting.&amp;nbsp;The numbers&amp;nbsp;8.400000000008E-11 and&amp;nbsp;8.400000000000E-11 differ by only 8E-23 &amp;lt; 1E-12.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;SAS cannot represent numbers exactly that are more than about 15 significant digits.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is true, but the numbers involved here have only up to 13 significant digits, so SAS can handle them fairly well. Only &lt;EM&gt;fairly&lt;/EM&gt; well, though, because the case of 8.400000000012E+11 is an example where the internal representation depends on whether scientific notation is used in the literal:&lt;/P&gt;
&lt;PRE&gt;430   data _null_;
431   x=840000000001.2;
432   y=8.400000000012E+11;
433   if x ne y then put 'Surprise!';
434   put (x y) (=binary64./);
435   run;

Surprise!
x=0100001001101000011100100111110011011010000000000010011001100110
y=0100001001101000011100100111110011011010000000000010011001100111
&lt;/PRE&gt;
&lt;P&gt;(using Windows SAS 9.4M5).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here, the internal representation of &lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt; is mathematically correct, i.e., closer to the theoretical exact representation, which repeats the 4-digit pattern "0011" (occurring three times in the representation of &lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt;, followed by the last zero) infinitely often. The last bit (1) of the internal representation of &lt;FONT face="courier new,courier"&gt;y&lt;/FONT&gt; is actually the result of incorrectly rounding up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Translated back to the decimal system, the two internal representations look like this:&lt;/P&gt;
&lt;PRE&gt;x=840000000001.199951171875 
y=840000000001.2000732421875&lt;/PRE&gt;
&lt;P&gt;So we can see that the precision is clearly sufficient to distinguish either of these numbers from, say, 840000000001.0. The situation with the numbers close to 8.4E&lt;STRONG&gt;-&lt;/STRONG&gt;11 is quite similar because of the number of &lt;EM&gt;significant&lt;/EM&gt; digits. The eleven leading zeros in the decimal representation don't really matter (only a little bit if you try and enter them in a numeric literal, where, again, the internal representation may differ from that of the literal in scientific notation).&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jul 2024 16:35:10 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2024-07-01T16:35:10Z</dc:date>
    <item>
      <title>numeric format does not validate intervals properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934254#M367389</link>
      <description>&lt;P&gt;Consider this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format; 
  value xx 8.400000000008E+11- 
           8.400000000012E+11='x';
  value yy 8.400000000008E-11- 
           8.400000000012E-11='x';
data _null_;
         A=8.400000000010E+11; put A best20. '/ ' A xx20.;
         B=8.400000000000E+11; put B best20. '/ ' B xx20.;       
         C=8.400000000010E-11; put C best20. '/ ' C yy20.;
         D=8.400000000000e-11; put D best20. '/ ' D yy20.;       
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A and C are in the format interval, B and D are not.&lt;/P&gt;
&lt;P&gt;This generates:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;         840000000001/ x                   
         840000000000/         840000000000
    8.40000000001E-11/ x                   
              8.4E-11/ x                   
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;D is formatted when it shouldn't be.&lt;/P&gt;
&lt;P&gt;Is this a known behaviour?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 13:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934254#M367389</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-07-01T13:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: numeric format does not validate intervals properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934262#M367392</link>
      <description>&lt;P&gt;SAS cannot represent numbers exactly that are more than about 15 significant digits. See:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/comparing-two-values/m-p/761113#M240787" target="_blank"&gt;Machine Precision&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&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"&gt;Machine Precision part 2&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 13:58:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934262#M367392</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-01T13:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: numeric format does not validate intervals properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934276#M367394</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;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's the default value 1E-12 of the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1upn25lbfo6mkn1wncu4dyh9q91.htm#n0qhedcd1ls7ren1hn86ntotxrai" target="_blank" rel="noopener"&gt;FUZZ= option&lt;/A&gt; which causes this. Use FUZZ=0 (or, e.g., FUZZ=1E-23 in this example) to avoid the unwanted formatting.&amp;nbsp;The numbers&amp;nbsp;8.400000000008E-11 and&amp;nbsp;8.400000000000E-11 differ by only 8E-23 &amp;lt; 1E-12.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;SAS cannot represent numbers exactly that are more than about 15 significant digits.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is true, but the numbers involved here have only up to 13 significant digits, so SAS can handle them fairly well. Only &lt;EM&gt;fairly&lt;/EM&gt; well, though, because the case of 8.400000000012E+11 is an example where the internal representation depends on whether scientific notation is used in the literal:&lt;/P&gt;
&lt;PRE&gt;430   data _null_;
431   x=840000000001.2;
432   y=8.400000000012E+11;
433   if x ne y then put 'Surprise!';
434   put (x y) (=binary64./);
435   run;

Surprise!
x=0100001001101000011100100111110011011010000000000010011001100110
y=0100001001101000011100100111110011011010000000000010011001100111
&lt;/PRE&gt;
&lt;P&gt;(using Windows SAS 9.4M5).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here, the internal representation of &lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt; is mathematically correct, i.e., closer to the theoretical exact representation, which repeats the 4-digit pattern "0011" (occurring three times in the representation of &lt;FONT face="courier new,courier"&gt;x&lt;/FONT&gt;, followed by the last zero) infinitely often. The last bit (1) of the internal representation of &lt;FONT face="courier new,courier"&gt;y&lt;/FONT&gt; is actually the result of incorrectly rounding up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Translated back to the decimal system, the two internal representations look like this:&lt;/P&gt;
&lt;PRE&gt;x=840000000001.199951171875 
y=840000000001.2000732421875&lt;/PRE&gt;
&lt;P&gt;So we can see that the precision is clearly sufficient to distinguish either of these numbers from, say, 840000000001.0. The situation with the numbers close to 8.4E&lt;STRONG&gt;-&lt;/STRONG&gt;11 is quite similar because of the number of &lt;EM&gt;significant&lt;/EM&gt; digits. The eleven leading zeros in the decimal representation don't really matter (only a little bit if you try and enter them in a numeric literal, where, again, the internal representation may differ from that of the literal in scientific notation).&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 16:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934276#M367394</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-07-01T16:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: numeric format does not validate intervals properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934351#M367413</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;SAS cannot represent numbers exactly that are more than about 15 significant digits.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I am within that precision range here.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 23:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934351#M367413</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-07-01T23:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: numeric format does not validate intervals properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934352#M367414</link>
      <description>&lt;P&gt;Ah yes, I forgot about the fuzz option.&lt;/P&gt;
&lt;P&gt;Too much time spent away from SAS it seems...&lt;/P&gt;
&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 00:03:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/numeric-format-does-not-validate-intervals-properly/m-p/934352#M367414</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-07-02T00:03:52Z</dc:date>
    </item>
  </channel>
</rss>

