<?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 convert a character field to a numeric field without resulting in an exponent in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905783#M357708</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to convert a character field to a numeric field without resulting in an exponent when the value is long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data:&lt;/P&gt;
&lt;P&gt;obs&amp;nbsp; &amp;nbsp; Field1&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 123456789012345&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;P&gt;data Example;&lt;BR /&gt;set RawData;&lt;BR /&gt;Field2 = input(Field1, 16.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;obs&amp;nbsp; &amp;nbsp; Field2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.23456E14&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want as my result:&lt;/P&gt;
&lt;P&gt;obs&amp;nbsp; &amp;nbsp; Field2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 123456789012345&lt;/P&gt;</description>
    <pubDate>Fri, 01 Dec 2023 23:56:43 GMT</pubDate>
    <dc:creator>ChickenLittle</dc:creator>
    <dc:date>2023-12-01T23:56:43Z</dc:date>
    <item>
      <title>convert a character field to a numeric field without resulting in an exponent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905783#M357708</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to convert a character field to a numeric field without resulting in an exponent when the value is long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data:&lt;/P&gt;
&lt;P&gt;obs&amp;nbsp; &amp;nbsp; Field1&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 123456789012345&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;P&gt;data Example;&lt;BR /&gt;set RawData;&lt;BR /&gt;Field2 = input(Field1, 16.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;obs&amp;nbsp; &amp;nbsp; Field2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.23456E14&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want as my result:&lt;/P&gt;
&lt;P&gt;obs&amp;nbsp; &amp;nbsp; Field2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 123456789012345&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 23:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905783#M357708</guid>
      <dc:creator>ChickenLittle</dc:creator>
      <dc:date>2023-12-01T23:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: convert a character field to a numeric field without resulting in an exponent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905784#M357709</link>
      <description>&lt;P&gt;If you input data with a 16. informat use a 16 wide FORMAT assigned to the value.&lt;/P&gt;
&lt;P&gt;When you do not assign a format to a numeric value the default is BEST12. So stuffing 15 or 16 characters into 12 results in the Exponential display.&lt;/P&gt;
&lt;PRE&gt;data Example;
Field2 = input('123456789012345', 16.);
format field2 best16.;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are these "numbers" actually a measurement or something that you will do arithmetic? If not leave them as character.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2023 00:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905784#M357709</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-02T00:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: convert a character field to a numeric field without resulting in an exponent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905786#M357710</link>
      <description>&lt;P&gt;Thanks! And it is a key. But to spare me from modifying another original table, I'd rather just modify my table to match it.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2023 00:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905786#M357710</guid>
      <dc:creator>ChickenLittle</dc:creator>
      <dc:date>2023-12-02T00:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: convert a character field to a numeric field without resulting in an exponent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905787#M357711</link>
      <description>&lt;P&gt;The format basically would have no impact on use such as joining a different table as I guess might be the use of something you call a key.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A somewhat silly example where one value is formatted as date to demonstrate that the format does not impact the join on the values.&lt;/P&gt;
&lt;PRE&gt;data t1;
   input key value;
datalines;
12345  66
45612  99
;

data t2;
  input field1 othervalue;
  format field1 date9.;
datalines;
12345  99999
45612  88888
;

proc sql;
   create table example as
   select t1.*, t2.*
   from t1 as a
        left join
        t2 as b
   on t1.key=t2.field1
   ;
quit;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Dec 2023 00:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905787#M357711</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-02T00:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: convert a character field to a numeric field without resulting in an exponent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905795#M357713</link>
      <description>&lt;P&gt;You can store 16 digits as a number, but only up to the maximum integer that SAS can represent before it starts having to round values.&amp;nbsp; So unless you are positive the values will always be less than&amp;nbsp;9,007,199,254,740,992 you should keep it as character string.&amp;nbsp; There is no real reason to store identifiers as numbers since you won't be doing any arithmetic on them.&lt;/P&gt;
&lt;PRE&gt;45   data _null_;
46     maxint=constant('exactint');
47     len = length(cats(maxint));
48     put len= maxint=:comma32.;
49   run;

len=16 maxint=9,007,199,254,740,992
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2023 03:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-character-field-to-a-numeric-field-without-resulting/m-p/905795#M357713</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-02T03:41:49Z</dc:date>
    </item>
  </channel>
</rss>

