<?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: Convert long character to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-long-character-to-numeric/m-p/541393#M149460</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121317"&gt;@mansour_ib_sas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;BR /&gt;I want to convert a character variable to numeric.&lt;BR /&gt;The character variable as shown in this example contains occurrences that are long.&lt;BR /&gt;After conversion, the numerical result obtained is not the same with that which is the one in the varaible character.&lt;BR /&gt;How can I get the same numbers in both formats?&lt;/P&gt;
&lt;P&gt;Thank you&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 char_to_num;
/*Conversion Charatere to numeric  */
x_char1 = "123456789123456789123456123456";
x_num1 = input(x_char1,best32.);
format x_num1 best32.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You cannot.&lt;/P&gt;
&lt;P&gt;SAS stores numbers using 8 byte floating point values. You can only store about 15 digits of precision using that format.&lt;/P&gt;
&lt;P&gt;What calculations you going to do with such a large number anyway that needs to preserve such a large level of precision?&lt;/P&gt;
&lt;P&gt;If it is an identifier then keep it as a character string.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Mar 2019 13:26:55 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-03-08T13:26:55Z</dc:date>
    <item>
      <title>Convert long character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-long-character-to-numeric/m-p/541390#M149459</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I want to convert a character variable to numeric.&lt;BR /&gt;The character variable as shown in this example contains occurrences that are long.&lt;BR /&gt;After conversion, the numerical result obtained is not the same with that which is the one in the varaible character.&lt;BR /&gt;How can I get the same numbers in both formats?&lt;/P&gt;&lt;P&gt;Thank you&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 char_to_num;
/*Conversion Charatere to numeric  */
x_char1 = "123456789123456789123456123456";
x_num1 = input(x_char1,best32.);
format x_num1 best32.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Mar 2019 13:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-long-character-to-numeric/m-p/541390#M149459</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2019-03-08T13:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Convert long character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-long-character-to-numeric/m-p/541393#M149460</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121317"&gt;@mansour_ib_sas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;BR /&gt;I want to convert a character variable to numeric.&lt;BR /&gt;The character variable as shown in this example contains occurrences that are long.&lt;BR /&gt;After conversion, the numerical result obtained is not the same with that which is the one in the varaible character.&lt;BR /&gt;How can I get the same numbers in both formats?&lt;/P&gt;
&lt;P&gt;Thank you&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 char_to_num;
/*Conversion Charatere to numeric  */
x_char1 = "123456789123456789123456123456";
x_num1 = input(x_char1,best32.);
format x_num1 best32.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You cannot.&lt;/P&gt;
&lt;P&gt;SAS stores numbers using 8 byte floating point values. You can only store about 15 digits of precision using that format.&lt;/P&gt;
&lt;P&gt;What calculations you going to do with such a large number anyway that needs to preserve such a large level of precision?&lt;/P&gt;
&lt;P&gt;If it is an identifier then keep it as a character string.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 13:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-long-character-to-numeric/m-p/541393#M149460</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-08T13:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert long character to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-long-character-to-numeric/m-p/541396#M149461</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you for Ansewer.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;It's for&amp;nbsp;&lt;SPAN&gt;If identifier.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I did an itirative test, and I arrived at a precision level of 17&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data char_to_num;&lt;BR /&gt;/*Conversion Charatere to numeric */&lt;BR /&gt;x_char1 = "123456789123456789123456123456";&lt;BR /&gt;x_num1 = input(x_char1,17.);&lt;BR /&gt;format x_num1 best32.2;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 13:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-long-character-to-numeric/m-p/541396#M149461</guid>
      <dc:creator>mansour_ib_sas</dc:creator>
      <dc:date>2019-03-08T13:34:24Z</dc:date>
    </item>
  </channel>
</rss>

