<?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: Count the number of digits before decimal and after decimal in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-the-number-of-digits-before-decimal-and-after-decimal/m-p/522472#M141858</link>
    <description>&lt;P&gt;try this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input amount 8.;
cards;
9581.1728
398.3543
12.12
1.12
;
run;

data want;
  set test;
  char=compress(amount||"","");
  len=length(char);
  dot=indexc(char,".");
  before=dot-1;
  after=len-dot;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Dec 2018 10:42:04 GMT</pubDate>
    <dc:creator>ShiroAmada</dc:creator>
    <dc:date>2018-12-19T10:42:04Z</dc:date>
    <item>
      <title>Count the number of digits before decimal and after decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-the-number-of-digits-before-decimal-and-after-decimal/m-p/522467#M141855</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Hi all,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;i've a dataset like given bellow&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;N_&lt;/TD&gt;&lt;TD&gt;36&lt;/TD&gt;&lt;TD&gt;36&lt;/TD&gt;&lt;TD&gt;36&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Mt_&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;9581.1728&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;9791.5262&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;1366.1106&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S_D&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;2965.8626&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;2982.0749 &lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;398.3543&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Now i need to give decimal places for the variables what if other variables contain more decimal places how to find out that .i had tried many things like format, length and etc. but it didn't work well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;is it really possible? if so, can anyone tell me how?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial, sans-serif;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 10:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-the-number-of-digits-before-decimal-and-after-decimal/m-p/522467#M141855</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2018-12-19T10:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of digits before decimal and after decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-the-number-of-digits-before-decimal-and-after-decimal/m-p/522470#M141856</link>
      <description>&lt;P&gt;You dont have a dataset like that, you can't have 36 as a variable name, nor can you have multiple of the same variable.&amp;nbsp; Please post test data in the form of a datastep in future:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As such I can only speak generally in that:&lt;/P&gt;
&lt;PRE&gt;data want;
  have=9581.1728;
  want=lenthn(scan(put(have,best.),2,"."));
run;&lt;/PRE&gt;
&lt;P&gt;So I take the second word from the number after putting it to text, delimited by ., then lengthn() to get how many characters.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 10:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-the-number-of-digits-before-decimal-and-after-decimal/m-p/522470#M141856</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-19T10:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of digits before decimal and after decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-the-number-of-digits-before-decimal-and-after-decimal/m-p/522472#M141858</link>
      <description>&lt;P&gt;try this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input amount 8.;
cards;
9581.1728
398.3543
12.12
1.12
;
run;

data want;
  set test;
  char=compress(amount||"","");
  len=length(char);
  dot=indexc(char,".");
  before=dot-1;
  after=len-dot;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 10:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-the-number-of-digits-before-decimal-and-after-decimal/m-p/522472#M141858</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2018-12-19T10:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of digits before decimal and after decimal</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-the-number-of-digits-before-decimal-and-after-decimal/m-p/522474#M141859</link>
      <description>thank you</description>
      <pubDate>Wed, 19 Dec 2018 10:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-the-number-of-digits-before-decimal-and-after-decimal/m-p/522474#M141859</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2018-12-19T10:51:39Z</dc:date>
    </item>
  </channel>
</rss>

