<?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 sql 15-character to number in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896193#M354097</link>
    <description>&lt;P&gt;The biggest integer SAS can store with full precision got 16 digits:&amp;nbsp;9007199254740992&lt;/P&gt;
&lt;P&gt;The string in your example got only 15 digits and though SAS can store it with full precision in a numerical variable (see example below).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure where you are losing precision but it's highly likely not happening within SAS if what you show us is what you've got.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;&lt;BR /&gt;  length WOOW $16;
  WOOW='9007199254740992'; output;
  WOOW='744811391691773'; output;
run;

proc sql;
  select input(WOOW,best16.) as WOOW_NUM format=best32.
  from have
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1695884000442.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88391iD8EB406082D87432/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1695884000442.png" alt="Patrick_0-1695884000442.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Sep 2023 06:56:57 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2023-09-28T06:56:57Z</dc:date>
    <item>
      <title>proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896134#M354065</link>
      <description>&lt;P&gt;hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;my input replaces last seven digits with zeros. please help!&lt;/P&gt;&lt;P&gt;here's code&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;create table AAA as&lt;BR /&gt;select input(WOOW,&amp;nbsp; best15.) as WOOW_NUM&lt;BR /&gt;from TABLE&lt;BR /&gt;where BLAHBLAHBLAH&lt;BR /&gt;group by 1&lt;BR /&gt;order by 1 desc&lt;BR /&gt;; quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here's original WOOW string:&lt;/P&gt;&lt;P&gt;744811391691773&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here's what I am getting back:&amp;nbsp;&lt;/P&gt;&lt;P&gt;744811390000000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;many thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 19:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896134#M354065</guid>
      <dc:creator>ilya1</dc:creator>
      <dc:date>2023-09-27T19:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896141#M354069</link>
      <description>&lt;P&gt;Some 15 digit numbers (and longer numbers) must be stored as character strings. SAS cannot represent some 15 digits (or longer) numbers exactly, as you have seen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This has nothing to do with PROC SQL&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 19:09:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896141#M354069</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-09-27T19:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896142#M354070</link>
      <description>hmm.. that's not useful. i need the numbers to load into a subsequent query.</description>
      <pubDate>Wed, 27 Sep 2023 19:13:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896142#M354070</guid>
      <dc:creator>ilya1</dc:creator>
      <dc:date>2023-09-27T19:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896144#M354072</link>
      <description>&lt;P&gt;What is&amp;nbsp;&lt;SPAN&gt;WOOW? If it's not a measure then leave it as character as 15 digits is at the maximum of what a SAS numeric variable can hold accurately.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you must convert, try adding a format to ensure 15 digits are displayed.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
create table AAA as
select input(WOOW,  best15.) as WOOW_NUM format = 15.
from TABLE
where BLAHBLAHBLAH
group by 1
order by 1 desc
; quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Sep 2023 19:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896144#M354072</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-09-27T19:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896147#M354074</link>
      <description>need WOOW to run subquery against in a different database where it is a number. so formats mismatch is an issue.</description>
      <pubDate>Wed, 27 Sep 2023 19:21:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896147#M354074</guid>
      <dc:creator>ilya1</dc:creator>
      <dc:date>2023-09-27T19:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896148#M354075</link>
      <description>&lt;P&gt;A DATA step for your example works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;;
  var = '744811391691773';
  var_num = input(var, best15.);
  format var_num best15.;
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Sep 2023 19:22:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896148#M354075</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-09-27T19:22:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896149#M354076</link>
      <description>&lt;P&gt;You can CAST or INPUT a character variable to a number in SQL to get the column types to align in another database.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 19:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896149#M354076</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-09-27T19:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896150#M354077</link>
      <description>&lt;P&gt;In SQL you can match to the 15 digit number converted to character&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
on a.fifteendigitcharvar=put(fifteendigitnumber,15.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Sep 2023 19:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896150#M354077</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-09-27T19:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896193#M354097</link>
      <description>&lt;P&gt;The biggest integer SAS can store with full precision got 16 digits:&amp;nbsp;9007199254740992&lt;/P&gt;
&lt;P&gt;The string in your example got only 15 digits and though SAS can store it with full precision in a numerical variable (see example below).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure where you are losing precision but it's highly likely not happening within SAS if what you show us is what you've got.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;&lt;BR /&gt;  length WOOW $16;
  WOOW='9007199254740992'; output;
  WOOW='744811391691773'; output;
run;

proc sql;
  select input(WOOW,best16.) as WOOW_NUM format=best32.
  from have
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1695884000442.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88391iD8EB406082D87432/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1695884000442.png" alt="Patrick_0-1695884000442.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2023 06:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896193#M354097</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-09-28T06:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896273#M354141</link>
      <description>&lt;P&gt;There is a limit on the precision that SAS/Access can transfer that is a little lower than the actual precision that SAS can store.&amp;nbsp; So even if your 15 digit numbers might be smaller than the maximum contiguous integer that SAS can store.&lt;/P&gt;
&lt;PRE&gt;500  data _null_;
501    max=constant('exactint');
502    put max=comma24.;
503  run;

max=9,007,199,254,740,992
&lt;/PRE&gt;
&lt;P&gt;you might still be losing precision by trying to transfer the value as a number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Convert the value to a string and transfer it as a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to convert the value to a string not the same on every database, so look up the syntax for your system.&amp;nbsp; Usually they have implemented some version of CAST() function to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you might get the list of values from one database (or table).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table list as
  select * from connection to mydb
( select cast(large_decimal_var as char(20)) as ids
  from myschema.mytable1
) ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then upload the list of values into another database&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table mylib2.list as select * from list;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use that list of subset data from a table there.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table final as 
select * from connection to mydb2 
(select a.* from aschema.atable a
  where large_decimal_value in (select cast(id as decimal(20)) from tempschema.list)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Sep 2023 15:21:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896273#M354141</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-28T15:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896358#M354168</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;There is a limit on the precision that SAS/Access can transfer that is a little lower than the actual precision that SAS can store.&amp;nbsp; So even if your 15 digit numbers might be smaller than the maximum contiguous integer that SAS can store.&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Can you please share where that's documented and how to figure out what the biggest integer for full precision in such a scenario is. I'm only aware of docu entry&lt;A href="https://go.documentation.sas.com/doc/en/lrcon/9.4/p0ji1unv6thm0dn1gp4t01a1u0g6.htm" target="_self"&gt; Numerical Accuracy in SAS Software&lt;/A&gt; which doesn't mention such SAS/Access specifics.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2023 00:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896358#M354168</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-09-29T00:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 15-character to number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896371#M354179</link>
      <description>&lt;P&gt;Two things happening here: the number is larger than the source by a factor of 10, and it is rounded by 1&lt;SPAN&gt;0000000. With the code you show, this CAN NOT HAPPEN, period. Please show the complete log from your&amp;nbsp;&lt;U&gt;real&lt;/U&gt; code.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2023 05:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-15-character-to-number/m-p/896371#M354179</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-09-29T05:23:02Z</dc:date>
    </item>
  </channel>
</rss>

