<?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: FINDC not producing expected results in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433261#M281853</link>
    <description>&lt;P&gt;If there is only one decimal&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;num=length(lbstresc) - findc(lbstresc,&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'.'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;)+&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;if you have more decimals and need the last then you'll need to provide more details.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Feb 2018 20:23:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-02-01T20:23:36Z</dc:date>
    <item>
      <title>FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433247#M281849</link>
      <description>&lt;P&gt;I am working on SAS version 9.4. I have a value LBSTRESC='&amp;lt;10.0'. I need to determine how many digits are present in LBSTRESC to the right of the decimal. I thought that the FINDC function would be appropriate. I tried several different combinations of startpos and modifier arguments shown below (and possibly more that produced unexpected results):&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;lbstresc='&amp;lt;10.0';
&amp;nbsp;
num=findc(lbstresc,'.',-1);
num=findc(lbstresc,'.','b');
num=findc(lbstresc,'.',-1,'b');
num=findc(lbstresc,'.',-10);
num=findc(lbstresc,'.',-10,'b');
num=findc(lbstresc,'.',10,'b');
num=findc(lbstresc,'.',1,'b');&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;All of these attempts gave me num=0 or num=4. Can someone help me correctly execute this function so that I can get num=2, as in the decimal place is the second value from the right to the left? Thank you!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 19:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433247#M281849</guid>
      <dc:creator>kli15</dc:creator>
      <dc:date>2018-02-01T19:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433252#M281850</link>
      <description>&lt;P&gt;You wrote-&lt;EM&gt;"how many digits are present in LBSTRESC to the right of the decimal"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN&gt;Can someone help me correctly execute this function so that I can get num=2&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is the expected num=2 in&amp;nbsp;'&amp;lt;10.0'&amp;nbsp;to the right of the decimal?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 20:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433252#M281850</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-01T20:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433253#M281851</link>
      <description>&lt;P&gt;Are you looking for something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
lbstresc='&amp;lt;10.0000';
num=findc(lbstresc,'.');
count=lengthn(substr(lbstresc,num+1));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Feb 2018 20:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433253#M281851</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-01T20:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433260#M281852</link>
      <description>&lt;P&gt;I’m assuming this isn’t for a single value, so can you post some more data to ensure the solution works with your data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option, use SCAN() with period as the delimiter and single quote and you’ll extract only the numbers behind the decimal. Is the assumption here you’re trying to extract the number?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 20:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433260#M281852</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-01T20:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433261#M281853</link>
      <description>&lt;P&gt;If there is only one decimal&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;num=length(lbstresc) - findc(lbstresc,&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'.'&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;)+&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;if you have more decimals and need the last then you'll need to provide more details.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 20:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433261#M281853</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-01T20:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433265#M281855</link>
      <description>&lt;P&gt;Looks like you are getting the number you asked for. The period is in the 4th position.&amp;nbsp; If you want to know how many characters follow it then subtract that from the total length.&amp;nbsp; Add 1 if you want to include the period itself.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;decimals = length(x) - findc(x,'.') + 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could try flipping the the string around instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;decimals = findc(reverse(trim(x)),'.');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Feb 2018 20:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433265#M281855</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-02-01T20:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433269#M281856</link>
      <description>&lt;P&gt;This helped point me in the right direction. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 20:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433269#M281856</guid>
      <dc:creator>kli15</dc:creator>
      <dc:date>2018-02-01T20:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433270#M281857</link>
      <description>This helped point me in the right direction. Thanks!</description>
      <pubDate>Thu, 01 Feb 2018 20:58:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433270#M281857</guid>
      <dc:creator>kli15</dc:creator>
      <dc:date>2018-02-01T20:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433271#M281858</link>
      <description>However, I still don't understand how 4 is what I asked for. I used the 'b' modifier which should read the characters from right to left. But this code works as an alternative.</description>
      <pubDate>Thu, 01 Feb 2018 21:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433271#M281858</guid>
      <dc:creator>kli15</dc:creator>
      <dc:date>2018-02-01T21:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433277#M281859</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40016"&gt;@kli15&lt;/a&gt; wrote:&lt;BR /&gt;However, I still don't understand how 4 is what I asked for. I used the 'b' modifier which should read the characters from right to left. But this code works as an alternative.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The &lt;STRONG&gt;position&lt;/STRONG&gt; number of the string remains the same (4) when found whether you search from the left or right. Note that the function does not say the number of characters from the start position.&lt;/P&gt;
&lt;P&gt;The assumption when using a start position is that you have some reason to start there.&lt;/P&gt;
&lt;P&gt;Consider&lt;/P&gt;
&lt;PRE&gt;data junk;
lbstresc='some.thing.with multiple.';

num=findc(lbstresc,'.',findc(lbstresc,'.')+1);

run;&lt;/PRE&gt;
&lt;P&gt;The start position for the outer findc is 1 more than the position of the first decimal&amp;nbsp;. So the found decimal is the one after "thing". Which has position 11 in this example string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 21:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433277#M281859</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-01T21:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433301#M281860</link>
      <description>I see, thank you so much for the explanation! First time using findc and I have been so confused!</description>
      <pubDate>Thu, 01 Feb 2018 22:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433301#M281860</guid>
      <dc:creator>kli15</dc:creator>
      <dc:date>2018-02-01T22:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: FINDC not producing expected results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433324#M281861</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40016"&gt;@kli15&lt;/a&gt; wrote:&lt;BR /&gt;I see, thank you so much for the explanation! First time using findc and I have been so confused!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You aren't the first and won't be the last.&lt;/P&gt;
&lt;P&gt;I seem to remember similar confusion a few times in the past. And SAS was something like the 7th programming language (plus 5 or 6 dialects of Basic) I learned.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 23:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FINDC-not-producing-expected-results/m-p/433324#M281861</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-01T23:40:33Z</dc:date>
    </item>
  </channel>
</rss>

