<?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: value precision issue in data extracted from snowflake in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796330#M255522</link>
    <description>Thanks, Reeze!&lt;BR /&gt;&lt;BR /&gt;Here any difference is my concern to find a solution, regardless the significance.</description>
    <pubDate>Tue, 15 Feb 2022 16:41:50 GMT</pubDate>
    <dc:creator>leehsin</dc:creator>
    <dc:date>2022-02-15T16:41:50Z</dc:date>
    <item>
      <title>value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796317#M255513</link>
      <description>&lt;P&gt;Hi, I had two data sets and encountered an issue that the value in a data set extracted from Snowflake are slightly different to the original value stored in SAS data set. See the example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;DATA_SF&amp;nbsp; &amp;nbsp; &amp;nbsp; DATA_Ori&lt;BR /&gt;COST_AMT&amp;nbsp; &amp;nbsp; &amp;nbsp;COST_AMT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Diff.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %Diff&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 44.48&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 44.48&amp;nbsp; &amp;nbsp; &amp;nbsp; 7.11E-15&amp;nbsp; &amp;nbsp; &amp;nbsp; 1.60E-14&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8.88E-16&amp;nbsp; &amp;nbsp; &amp;nbsp; 1.74E-14&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My questions: What could be the reason for this different? Suggestion?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 16:21:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796317#M255513</guid>
      <dc:creator>leehsin</dc:creator>
      <dc:date>2022-02-15T16:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796323#M255518</link>
      <description>&lt;P&gt;Numeric precision - basically computers aren't perfect and can't track decimals exactly after a certain point.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p0dv87zb3bnse6n1mqo360be70qr.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p0dv87zb3bnse6n1mqo360be70qr.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is a difference of 0.0000000000000711 of significance to you?&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/215142"&gt;@leehsin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I had two data sets and encountered an issue that the value in a data set extracted from Snowflake are slightly different to the original value stored in SAS data set. See the example:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;DATA_SF&amp;nbsp; &amp;nbsp; &amp;nbsp; DATA_Ori&lt;BR /&gt;COST_AMT&amp;nbsp; &amp;nbsp; &amp;nbsp;COST_AMT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Diff.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %Diff&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 44.48&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 44.48&amp;nbsp; &amp;nbsp; &amp;nbsp; 7.11E-15&amp;nbsp; &amp;nbsp; &amp;nbsp; 1.60E-14&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5.1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8.88E-16&amp;nbsp; &amp;nbsp; &amp;nbsp; 1.74E-14&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My questions: What could be the reason for this different? Suggestion?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 16:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796323#M255518</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-15T16:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796324#M255519</link>
      <description>&lt;P&gt;SAS stores all numbers in &lt;A href="https://en.wikipedia.org/wiki/Double-precision_floating-point_format" target="_blank" rel="noopener"&gt;64 bits (8 bytes) floating point&lt;/A&gt;. This leads to precision limitations (see the linked article), and if your other data source uses another storage format, there will be differences.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 16:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796324#M255519</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-15T16:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796325#M255520</link>
      <description>&lt;P&gt;E-15 range of differences likely points to precision of different machines as very likely issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are actually only using two decimal places then round or truncate the data to the required precision you use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 16:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796325#M255520</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-15T16:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796330#M255522</link>
      <description>Thanks, Reeze!&lt;BR /&gt;&lt;BR /&gt;Here any difference is my concern to find a solution, regardless the significance.</description>
      <pubDate>Tue, 15 Feb 2022 16:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796330#M255522</guid>
      <dc:creator>leehsin</dc:creator>
      <dc:date>2022-02-15T16:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796338#M255524</link>
      <description>Thanks Ballardw!&lt;BR /&gt;&lt;BR /&gt;The values start with 44.48, 5.1 in a SAS dataset. The dataset was uploaded to Snowflake. Then a request from a user asks to extract data from the Snowflake for another task, and the values change in the new dataset. Though it is acceptable in this case, will this kind of change accumulates by time and becomes an issue for a small value? I am seeking a way that I can get the unchanged value in the extraction data, if this way technically exists.</description>
      <pubDate>Tue, 15 Feb 2022 16:57:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796338#M255524</guid>
      <dc:creator>leehsin</dc:creator>
      <dc:date>2022-02-15T16:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796339#M255525</link>
      <description>Thanks Ballardw !&lt;BR /&gt;&lt;BR /&gt;The values start with 44.48, 5.1 in a SAS dataset. The dataset was uploaded to Snowflake. Then a request from a user asks to extract data from the Snowflake for another task, and the values change in the new dataset. Though it is acceptable in this case, will this kind of change accumulates by time and becomes an issue for a small value? I am seeking a way that I can get the unchanged value in the extraction data, if this way technically exists.</description>
      <pubDate>Tue, 15 Feb 2022 16:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796339#M255525</guid>
      <dc:creator>leehsin</dc:creator>
      <dc:date>2022-02-15T16:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796340#M255526</link>
      <description>Thanks, Kurt!</description>
      <pubDate>Tue, 15 Feb 2022 16:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796340#M255526</guid>
      <dc:creator>leehsin</dc:creator>
      <dc:date>2022-02-15T16:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796341#M255527</link>
      <description>There is no change in the data. The small error is negligible and something you'll find with all computers. If you check the snowflake data against the original data source you'll likely find the same differences. Computers typically store data with a set precision of up to 16 decimal points and you're differences are after that point. What is the precision requirement for your data?&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Feb 2022 17:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796341#M255527</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-15T17:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796342#M255528</link>
      <description>&lt;P&gt;You will often find such differences when moving across application and/or architecture borders. We found differences between SAS on the mainframe and SAS on UNIX/Windows simply because the MF uses more bits in the mantissa.&lt;/P&gt;
&lt;P&gt;So, once you verified how the differences originate and that they are statistically insignificant (which you have done), live with them.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 17:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796342#M255528</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-15T17:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796393#M255554</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215142"&gt;@leehsin&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would make sure that the values are &lt;EM&gt;correct&lt;/EM&gt; if they are processed later on. Otherwise these small rounding errors (7.11E-15 etc.) can cause unwanted issues in all sorts of comparisons, including IF or WHERE conditions, assignment of user-defined format categories, merging and sorting. Similar errors can arise from calculations, even within SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data_ori;
input cost_amt;
cards;
44.48
5.1
;

data data_sf;
set data_ori;
cost_amt=cost_amt*449/449;
run;

proc compare data=data_sf c=data_ori;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result (using Windows SAS 9.4M5)&lt;FONT face="helvetica"&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;           ||       Base    Compare
       Obs ||   cost_amt   cost_amt      Diff.     % Diff
 ________  ||  _________  _________  _________  _________
           ||
        1  ||    44.4800    44.4800  7.105E-15  1.597E-14
        2  ||     5.1000     5.1000  8.882E-16  1.742E-14&lt;/PRE&gt;
&lt;P&gt;In both cases the calculation (seemingly a multiplication by 1) has reduced the result by one unit of the least significant bit in the internal binary floating-point representation, namely &lt;FONT face="courier new,courier"&gt;2**-47=7.105...E-15&lt;/FONT&gt; in the case of 44.48 and &lt;FONT face="courier new,courier"&gt;2**-50=8.8817...E-16&lt;/FONT&gt; for 5.1. You can notice the errors in the HEX16. format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=data_sf;
format cost_amt hex16.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs            cost_amt

 1     40463D70A3D70A3&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;C&lt;/FONT&gt;&lt;/STRONG&gt;
 2     401466666666666&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;Even without seeing the corresponding representations of the original values (in &lt;FONT face="courier new,courier"&gt;data_ori&lt;/FONT&gt;) it's fairly obvious that the correct last hex digits should be D and 6, respectively (in view of the repeating digit patterns). So, look at a few of your values in HEX16. format to find out where the errors have occurred.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Besides calculations,&amp;nbsp;"&lt;SPAN&gt;moving [data] across application and/or architecture borders" is a common way of introducing this type of rounding (or numeric representation) errors, as mentioned by &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562" target="_self"&gt;Kurt_Bremser&lt;/A&gt;. I would follow &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_blank" rel="noopener"&gt;ballardw&lt;/A&gt;'s advice and correct the errors (in SAS) by applying the ROUND function with an appropriate rounding unit (which depends a bit on your data).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set data_sf;
cost_amt=round(cost_amt,1e-7);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 20:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796393#M255554</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-02-15T20:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796530#M255610</link>
      <description>&lt;P&gt;Try options METHOD= and FUZZ= :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data_ori;
input cost_amt;
cards;
44.48
5.1
;

data data_sf;
set data_ori;
cost_amt=cost_amt*449/449;
run;

proc compare data=data_sf c=data_ori method=relative fuzz=1E-10;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Feb 2022 12:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/796530#M255610</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-02-16T12:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: value precision issue in data extracted from snowflake</title>
      <link>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/798105#M313790</link>
      <description>Thank you, FreelanceReinhard! Great explanation!&lt;BR /&gt;Actually I did use round function to the concerned variables in both data when making comparisons, but this is the aftermath solution when the issues appear. If I could prevent this kind of issue from happening at the beginning when I extract a data from Snowflake, I would be happy not going back to repeat the process by applying the solution because this issue is not a real issue actually but may give you a surprise for having a overwhelming long list of data inconsistency, and repeating a process sometime is a very time consuming step in a project having many steps.</description>
      <pubDate>Wed, 23 Feb 2022 17:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/value-precision-issue-in-data-extracted-from-snowflake/m-p/798105#M313790</guid>
      <dc:creator>leehsin</dc:creator>
      <dc:date>2022-02-23T17:09:19Z</dc:date>
    </item>
  </channel>
</rss>

