<?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: To Find the length of numeric variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/To-Find-the-length-of-numeric-variable/m-p/74446#M21605</link>
    <description>Be careful with really long numbers.  SAS stores all numbers in floating point and can only represent integers to certain level of precision.  See the companion for your OS to determine the maximum length of an integer that can be represented for a particular number of bytes of storage.</description>
    <pubDate>Wed, 18 Feb 2009 14:24:11 GMT</pubDate>
    <dc:creator>Doc_Duke</dc:creator>
    <dc:date>2009-02-18T14:24:11Z</dc:date>
    <item>
      <title>To Find the length of numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/To-Find-the-length-of-numeric-variable/m-p/74444#M21603</link>
      <description>I have anumeric variable no i want the length of that numeric variable &lt;BR /&gt;
&lt;BR /&gt;
data l;&lt;BR /&gt;
input sal;&lt;BR /&gt;
cards;&lt;BR /&gt;
5449844894949849&lt;BR /&gt;
17188&lt;BR /&gt;
5454548978754545415&lt;BR /&gt;
211151&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Dont keep $ after sal.if i keep $ after sal i am getting but i want it in numeric only</description>
      <pubDate>Wed, 18 Feb 2009 09:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/To-Find-the-length-of-numeric-variable/m-p/74444#M21603</guid>
      <dc:creator>R_Win</dc:creator>
      <dc:date>2009-02-18T09:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: To Find the length of numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/To-Find-the-length-of-numeric-variable/m-p/74445#M21604</link>
      <description>Hi sas_user,&lt;BR /&gt;
&lt;BR /&gt;
int(log10(sal))+1; &lt;BR /&gt;
&lt;BR /&gt;
will give you the length of the number, assuming no decimals. You then just need to find the maximum, either using proc sql, a data step or another proc.</description>
      <pubDate>Wed, 18 Feb 2009 10:15:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/To-Find-the-length-of-numeric-variable/m-p/74445#M21604</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-18T10:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: To Find the length of numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/To-Find-the-length-of-numeric-variable/m-p/74446#M21605</link>
      <description>Be careful with really long numbers.  SAS stores all numbers in floating point and can only represent integers to certain level of precision.  See the companion for your OS to determine the maximum length of an integer that can be represented for a particular number of bytes of storage.</description>
      <pubDate>Wed, 18 Feb 2009 14:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/To-Find-the-length-of-numeric-variable/m-p/74446#M21605</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2009-02-18T14:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: To Find the length of numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/To-Find-the-length-of-numeric-variable/m-p/74447#M21606</link>
      <description>If there were decimals, then, not withstanding Doc's comments, something like this might help:&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
input sal $ 48.;&lt;BR /&gt;
cards;&lt;BR /&gt;
54498448949.49849&lt;BR /&gt;
171.88&lt;BR /&gt;
5454548978.754545415&lt;BR /&gt;
2111.51&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;set have end = eof;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;retain int 0;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;retain dec 0;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;array digits(2);&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;digits(1) = scan(sal,1,'.');&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;digits(2) = scan(sal,2,'.');&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;if input(digits(1), 32.) gt int then int = digits(1);&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;if input(digits(2), 32.) gt dec then dec = digits(2);&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;if eof then do;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i = compress(int(log10(int))+1);&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d = compress(int(log10(dec))+1);&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t = compress(int(log10(int))+1 + int(log10(dec))+1 + 1) || '.' || compress(int(log10(dec))+1);&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;put 'NOTE: Integers: ' i ' Decimals: ' d ' suggested format: ' t;&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Which gave me a message like this:&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Integers: 11  Decimals: 9  suggested format: 21.9</description>
      <pubDate>Wed, 18 Feb 2009 17:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/To-Find-the-length-of-numeric-variable/m-p/74447#M21606</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-18T17:33:37Z</dc:date>
    </item>
  </channel>
</rss>

