<?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 Have inserted numeric column to SQL table. Why is the value rounded? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Have-inserted-numeric-column-to-SQL-table-Why-is-the-value/m-p/904551#M357376</link>
    <description>&lt;P&gt;Hi guys!&lt;/P&gt;
&lt;P&gt;I've tried to insert numeric value to column in sql server.&amp;nbsp; I just want it to have exact value as the source column, but I don't know why the value in destination column is rounded.&lt;/P&gt;
&lt;P&gt;the source column is A.SubContractNo. The value is 510000029700000.&lt;/P&gt;
&lt;P&gt;the destination column value is&amp;nbsp;510000030000000.&lt;/P&gt;
&lt;P&gt;I expected it to have&amp;nbsp;510000029700000 as the source.&lt;/P&gt;
&lt;P&gt;The destination column is float type.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* my code does left join and then insert to the desination table*/
proc sql;
	insert into sqllib.output_tbl
	select A.ValueDate
	, A.RegisNo 
	, A.ContractNo
	, A.SubContractNo
	, A.ValueDate
	, B.Detail
	from work.input_tbl as A
	left join ssreout.detail_tbl as B
	on A.RegisNo = B.RegisNo
	and A.ValueDate = B.ValueDate
	where B.RegisNo is not null
	and B.ValueDate is not null;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 26 Nov 2023 14:06:41 GMT</pubDate>
    <dc:creator>Mayt</dc:creator>
    <dc:date>2023-11-26T14:06:41Z</dc:date>
    <item>
      <title>Have inserted numeric column to SQL table. Why is the value rounded?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-inserted-numeric-column-to-SQL-table-Why-is-the-value/m-p/904551#M357376</link>
      <description>&lt;P&gt;Hi guys!&lt;/P&gt;
&lt;P&gt;I've tried to insert numeric value to column in sql server.&amp;nbsp; I just want it to have exact value as the source column, but I don't know why the value in destination column is rounded.&lt;/P&gt;
&lt;P&gt;the source column is A.SubContractNo. The value is 510000029700000.&lt;/P&gt;
&lt;P&gt;the destination column value is&amp;nbsp;510000030000000.&lt;/P&gt;
&lt;P&gt;I expected it to have&amp;nbsp;510000029700000 as the source.&lt;/P&gt;
&lt;P&gt;The destination column is float type.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* my code does left join and then insert to the desination table*/
proc sql;
	insert into sqllib.output_tbl
	select A.ValueDate
	, A.RegisNo 
	, A.ContractNo
	, A.SubContractNo
	, A.ValueDate
	, B.Detail
	from work.input_tbl as A
	left join ssreout.detail_tbl as B
	on A.RegisNo = B.RegisNo
	and A.ValueDate = B.ValueDate
	where B.RegisNo is not null
	and B.ValueDate is not null;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Nov 2023 14:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-inserted-numeric-column-to-SQL-table-Why-is-the-value/m-p/904551#M357376</guid>
      <dc:creator>Mayt</dc:creator>
      <dc:date>2023-11-26T14:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Have inserted numeric column to SQL table. Why is the value rounded?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-inserted-numeric-column-to-SQL-table-Why-is-the-value/m-p/904552#M357377</link>
      <description>&lt;P&gt;SAS has trouble handling some 15-digit and above integers. Best to handle this as a character string, then no problems should result.&lt;/P&gt;</description>
      <pubDate>Sun, 26 Nov 2023 14:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-inserted-numeric-column-to-SQL-table-Why-is-the-value/m-p/904552#M357377</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-26T14:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: Have inserted numeric column to SQL table. Why is the value rounded?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-inserted-numeric-column-to-SQL-table-Why-is-the-value/m-p/904599#M357386</link>
      <description>&lt;P&gt;What is the storage length of subcontractno in the destination dataset (sqllib.output_tbl)?&amp;nbsp; And in the source dataset (work.input_tbl)?&amp;nbsp; Run a PROC CONTENTS against the dataset(s) to see what SAS thinks the storage length is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If subcontractno (as a floating point numeric value) is stored with a length of 6 or less, then there will be numeric precision problems for the value of 510000029700000.&amp;nbsp; On my windows machine, a length of 6 stores&amp;nbsp;510000029700000 as&amp;nbsp;510000029999104. And I believe this will be the case with unix machines as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But since that is not the same as 510000030000000 that you report, this may not be just a numeric precision issue (if it is a precision issue at all).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, you can run this test to see what various length attributes do when storing the value 510000029700000.&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 t;
  li=constant('exactint');
  length x8 8 x7 7  x6 6  x5 5  x4 4;
  array _x x: ;
  do over _x;
    _x=510000029700000;
  end;
run;
data _null_;
  set t;
  put li=16.0   ' Maximum consecutive exact integer ';
  array _x x: ;
  do over _x;
    put _x=z16.0 ;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which produces these values on my sas log:&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;li=9007199254740992  Maximum consecutive exact integer
x8=0510000029700000
x7=0510000029700000
x6=0510000029696000
x5=0510000028975104
x4=0509999985983488
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the end, this is a good reason to store ID values as character variables.&amp;nbsp; Which can cause other annoyances - but that is for another discussion.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2023 06:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-inserted-numeric-column-to-SQL-table-Why-is-the-value/m-p/904599#M357386</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-11-27T06:12:26Z</dc:date>
    </item>
  </channel>
</rss>

