<?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: Char to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835798#M330456</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to convert the following number to numeric but it is producing the value in exponential format. I need the value in numeric like how how it was in character without rounding and exponential format.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition to what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; said, this is obviously not a number (despite the fact that it only contains digits), it is some sort of ID variable, and there's no real reason to have this as a number. It's not like you're going to find an average of the ID values. So, your attempt to turn it into a number seems to be misguided. Leave it as character.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Sep 2022 11:36:09 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-09-29T11:36:09Z</dc:date>
    <item>
      <title>Char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835785#M330446</link>
      <description>&lt;P&gt;I'm trying to convert the following number to numeric but it is producing the value in exponential format. I need the value in numeric like how how it was in character without rounding and exponential format. Any help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
SKUNEW='002500000000011205';
SKUNEW2=input(SKUNEW,20.);
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Sep 2022 08:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835785#M330446</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2022-09-29T08:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835787#M330447</link>
      <description>&lt;P&gt;how about this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
SKUNEW='002500000000011205';
SKUNEW2=input(SKUNEW,20.);
format SKUNEW2 20.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Sep 2022 08:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835787#M330447</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-09-29T08:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835790#M330450</link>
      <description>&lt;P&gt;This conversion is not possible in a reliable way. Because of the way numeric data is stored, not more than 15 decimal digits can be precisely stored.&lt;/P&gt;
&lt;P&gt;Which statistic or calculation do you intend to do with these numbers?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 09:00:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835790#M330450</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-09-29T09:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835798#M330456</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to convert the following number to numeric but it is producing the value in exponential format. I need the value in numeric like how how it was in character without rounding and exponential format.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition to what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; said, this is obviously not a number (despite the fact that it only contains digits), it is some sort of ID variable, and there's no real reason to have this as a number. It's not like you're going to find an average of the ID values. So, your attempt to turn it into a number seems to be misguided. Leave it as character.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 11:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835798#M330456</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-29T11:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835810#M330464</link>
      <description>&lt;P&gt;I agree 100% with the advice that says don't do it.&amp;nbsp; You have decades of expert advice saying this ... SAS will not accurately convert long values to numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Within the SAS family of products, DS2 will let you get up to 19 digits, but not 20.&amp;nbsp; But I doubt you want to learn another programming language just to convert your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While none of the experts (myself included) think this is a good idea, you could still do something in SAS.&amp;nbsp; You could create two numeric variables instead of one.&amp;nbsp; Then modify your programming to utilize both variables.&amp;nbsp; Creating two is easy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;part1 = input(SKUNew, 10.);&lt;/P&gt;
&lt;P&gt;part2 = input(substr(SKUNew,11), 10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, subsequent programming with two variables instead of one is harder but can be done.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 11:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835810#M330464</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-09-29T11:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Char to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835828#M330468</link>
      <description>&lt;P&gt;Just to address two possible reasons for this problematic character-to-numeric conversion:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Do you work with software like an external database where such values are stored as numeric and you need to compare SKUNEW to those values?&lt;BR /&gt;Then convert those external values to character appropriately (i.e., considering leading zeros) before the comparison.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Do you really need to perform some numeric operation on SKUNEW (e.g., compute a checksum of some sort)?&lt;BR /&gt;This can be done using the existing digit strings in SKUNEW. See&amp;nbsp;&lt;A href="https://communities.sas.com/t5/New-SAS-User/Mod-function-with-big-number/m-p/546610/highlight/true#M8240" target="_blank" rel="noopener"&gt;Re: Mod function with big number&lt;/A&gt; for an example.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, again, the conclusion is (to let SAS speak for itself)&lt;FONT face="helvetica"&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;320   data _null_;
321   if input('00950000000001120&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/FONT&gt;',20.)=00950000000001120&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/FONT&gt; then put 'Leave it as character!';
322   run;

&lt;STRONG&gt;Leave it as character!&lt;/STRONG&gt;
NOTE: DATA statement used (Total process time):&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 12:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Char-to-numeric/m-p/835828#M330468</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-09-29T12:36:39Z</dc:date>
    </item>
  </channel>
</rss>

