<?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: Find function with negative starting position in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670464#M201276</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319930"&gt;@veda8&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Start position &lt;FONT face="courier new,courier"&gt;-10&lt;/FONT&gt; means:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The search starts at the 10th character of &lt;FONT face="courier new,courier"&gt;string&lt;/FONT&gt; (counted from the &lt;EM&gt;left&lt;/EM&gt;, as usual). In your example this is the capital &lt;FONT face="courier new,courier" size="4"&gt;W&lt;/FONT&gt;. If&amp;nbsp;&lt;FONT face="courier new,courier"&gt;lengthc(string)&amp;lt;10&lt;/FONT&gt;, the search would start at the &lt;EM&gt;end&lt;/EM&gt; of &lt;FONT face="courier new,courier"&gt;string&lt;/FONT&gt;.&lt;/LI&gt;
&lt;LI&gt;The direction of the search is to the left (because of the negative sign).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The result is always the position where the substring starts (counted from the &lt;EM&gt;left&lt;/EM&gt;) or zero if the substring is not found after reaching the end (beginning) of the string in case of a positive (negative) start position.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This explains both of your results. In particular, there is no &lt;FONT face="courier new,courier"&gt;" wo"&lt;/FONT&gt; (or &lt;FONT face="courier new,courier"&gt;" WO"&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;" wO"&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;" Wo"&lt;/FONT&gt;) contained in the part &lt;FONT face="courier new,courier"&gt;"How much W"&lt;/FONT&gt; of &lt;FONT face="courier new,courier"&gt;string&lt;/FONT&gt;&amp;nbsp;which the search is restricted to, whereas &lt;FONT face="courier new,courier"&gt;"much"&lt;/FONT&gt; is found in position 5 ff.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[Edit: Replaced &lt;FONT face="courier new,courier"&gt;length&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;length&lt;STRONG&gt;c&lt;/STRONG&gt;&lt;/FONT&gt; to be more precise.]&lt;/P&gt;</description>
    <pubDate>Sun, 19 Jul 2020 15:47:59 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2020-07-19T15:47:59Z</dc:date>
    <item>
      <title>Find function with negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670456#M201270</link>
      <description>&lt;P&gt;DATA TOUNGE;&lt;BR /&gt;STRING='How much WOOD would a woodchuck chuck';&lt;/P&gt;&lt;P&gt;num2=find(string,'much','i',-10);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;the output of this is 5&lt;/P&gt;&lt;P&gt;but when i use&amp;nbsp;num2=find(string,' wo','i',-10);&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;why is the output 0 and not 15?&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;when the postion reaches -startposition does it starts counting again from 1 ? and why do we get a positive no. and not negative no in output for position.&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Sun, 19 Jul 2020 14:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670456#M201270</guid>
      <dc:creator>veda8</dc:creator>
      <dc:date>2020-07-19T14:33:00Z</dc:date>
    </item>
    <item>
      <title>find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670460#M201273</link>
      <description />
      <pubDate>Sun, 19 Jul 2020 15:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670460#M201273</guid>
      <dc:creator>veda8</dc:creator>
      <dc:date>2020-07-19T15:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670461#M201272</link>
      <description>&lt;P&gt;The result is always a positive number since it is the index into the string for the starting character of the substring it found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you give a starting position the sign gives the direction and the magnitude gives the starting location.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So MUCH starts in position 5.&lt;/P&gt;
&lt;P&gt;But ' WO' does NOT exist between position 1 and 10 since the O is in position 11.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 15:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670461#M201272</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-19T15:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670462#M201274</link>
      <description>&lt;P&gt;Please do not post the same question multiple times (double-post).&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 15:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670462#M201274</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-19T15:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670463#M201275</link>
      <description>&lt;P&gt;Can you please explain what does -10 exactly mean?&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 15:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670463#M201275</guid>
      <dc:creator>veda8</dc:creator>
      <dc:date>2020-07-19T15:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670464#M201276</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319930"&gt;@veda8&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Start position &lt;FONT face="courier new,courier"&gt;-10&lt;/FONT&gt; means:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The search starts at the 10th character of &lt;FONT face="courier new,courier"&gt;string&lt;/FONT&gt; (counted from the &lt;EM&gt;left&lt;/EM&gt;, as usual). In your example this is the capital &lt;FONT face="courier new,courier" size="4"&gt;W&lt;/FONT&gt;. If&amp;nbsp;&lt;FONT face="courier new,courier"&gt;lengthc(string)&amp;lt;10&lt;/FONT&gt;, the search would start at the &lt;EM&gt;end&lt;/EM&gt; of &lt;FONT face="courier new,courier"&gt;string&lt;/FONT&gt;.&lt;/LI&gt;
&lt;LI&gt;The direction of the search is to the left (because of the negative sign).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The result is always the position where the substring starts (counted from the &lt;EM&gt;left&lt;/EM&gt;) or zero if the substring is not found after reaching the end (beginning) of the string in case of a positive (negative) start position.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This explains both of your results. In particular, there is no &lt;FONT face="courier new,courier"&gt;" wo"&lt;/FONT&gt; (or &lt;FONT face="courier new,courier"&gt;" WO"&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;" wO"&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;" Wo"&lt;/FONT&gt;) contained in the part &lt;FONT face="courier new,courier"&gt;"How much W"&lt;/FONT&gt; of &lt;FONT face="courier new,courier"&gt;string&lt;/FONT&gt;&amp;nbsp;which the search is restricted to, whereas &lt;FONT face="courier new,courier"&gt;"much"&lt;/FONT&gt; is found in position 5 ff.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[Edit: Replaced &lt;FONT face="courier new,courier"&gt;length&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;length&lt;STRONG&gt;c&lt;/STRONG&gt;&lt;/FONT&gt; to be more precise.]&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 15:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670464#M201276</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-07-19T15:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670465#M201277</link>
      <description>&lt;P&gt;The sign of -10 is NEGATIVE and the magnitude is 10.&amp;nbsp; So you are asking to search from right to left starting with the 10th position.&amp;nbsp; The substring has to fit completely into the area you are searching. So if the substring you are searching for is 3 bytes long then the first place (largest position) where you could possibly find it is position 8.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 15:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670465#M201277</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-19T15:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670467#M201278</link>
      <description>okay thank you so much</description>
      <pubDate>Sun, 19 Jul 2020 15:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670467#M201278</guid>
      <dc:creator>veda8</dc:creator>
      <dc:date>2020-07-19T15:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670468#M201279</link>
      <description>thank you so much&lt;BR /&gt;is it same for the scan function?&lt;BR /&gt;xyz='have a good day';&lt;BR /&gt;scan(xyz,-2) what does this do</description>
      <pubDate>Sun, 19 Jul 2020 15:37:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670468#M201279</guid>
      <dc:creator>veda8</dc:creator>
      <dc:date>2020-07-19T15:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670470#M201280</link>
      <description>&lt;P&gt;The logic for SCAN is different: Here the &lt;FONT face="courier new,courier"&gt;-2&lt;/FONT&gt; means the second word counted from the &lt;STRONG&gt;right&lt;/STRONG&gt; (in your example: &lt;FONT face="courier new,courier"&gt;"good"&lt;/FONT&gt;).&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 15:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670470#M201280</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-07-19T15:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Find function with negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670471#M201281</link>
      <description>&lt;P&gt;SCAN() is not "searching".&amp;nbsp; It is indexing.&amp;nbsp; So for scan negative numbers mean your count from right to left.&amp;nbsp; If there are 5 "words" in the string then you can get the 4th one using 4 or -2.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 15:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-function-with-negative-starting-position/m-p/670471#M201281</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-19T15:44:32Z</dc:date>
    </item>
  </channel>
</rss>

