<?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 - negative starting position in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638013#M189719</link>
    <description>&lt;P&gt;The -22 tells SAS to begin the search at the 22nd character starting from the right, which is the first s of "seashells". It then finds the string 'She' (ignoring case) beginning at character 14 of the string (which is in the inside of the word "seashells").&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2020 11:48:34 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-04-07T11:48:34Z</dc:date>
    <item>
      <title>find function - negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638009#M189717</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to understand starting position parameter in find function.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 xyz='She sells seashells? Yes, she does.';                                                                                             
   startposexp=-22;                                                                                                                      
   whereisShe_ineg22=find(xyz,'She','i',startposexp);                                                                                     
   put whereisShe_ineg22=;  
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In this example&amp;nbsp;&lt;CODE class=" language-sas"&gt;whereisShe_ineg22=14&lt;/CODE&gt;, Why?&lt;/P&gt;&lt;P&gt;As i understand, because the start position is negative, we start at the end of the string and count 22 places, and get the character s. Then the function start search to left, and to right. Why?&amp;nbsp; please see&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p00ab6ey29t2i8n1ihel88tqtga9.htm&amp;amp;docsetVersion=3.1&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p00ab6ey29t2i8n1ihel88tqtga9.htm&amp;amp;docsetVersion=3.1&amp;amp;locale=en&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 10:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638009#M189717</guid>
      <dc:creator>AlexeyS</dc:creator>
      <dc:date>2020-04-07T10:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: find function - negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638013#M189719</link>
      <description>&lt;P&gt;The -22 tells SAS to begin the search at the 22nd character starting from the right, which is the first s of "seashells". It then finds the string 'She' (ignoring case) beginning at character 14 of the string (which is in the inside of the word "seashells").&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 11:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638013#M189719</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-07T11:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: find function - negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638048#M189730</link>
      <description>&lt;P&gt;You are not understanding how it uses the absolute value when the starting position is negative.&lt;/P&gt;
&lt;P&gt;The first place where 'she' appears when searching backwards from byte 22 is byte 14.&lt;/P&gt;
&lt;P&gt;Does this picture help?&lt;/P&gt;
&lt;PRE&gt;She sells seashells? Yes, she does.
----+----0----+----0----+----0----+
             ^       ^
             |       +-&amp;gt; Position 22
             +&amp;gt; Position 14 &lt;/PRE&gt;
&lt;P&gt;actually if you change the search string from SHE to YES you can see that appear to behave as if it truncated the string at that position and then searches from the end of the truncated string backwards.&amp;nbsp; With a starting position of 24 or larger it finds YES when searching backwards.&amp;nbsp; But it does not find it when starting in position 22 or 23.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 14:18:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638048#M189730</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-07T14:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: find function - negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638074#M189735</link>
      <description>Hi Tom, i am still confused.&lt;BR /&gt;This definition i read in sas page : start-position is specified, the absolute value of start-position determines the position at which to start the search. The sign of start-position determines the direction of the search.&lt;BR /&gt;&lt;BR /&gt;I have to solution, which one is correct?&lt;BR /&gt;1. because start position is negative, i find position 22 from right to left, and then the search is standard from left to right?&lt;BR /&gt;2. to find start position i always use absolute value, i.e i find 22 position from left to right, and then because the direction is negative, i will look for the first occurrence of "she" from right to left?&lt;BR /&gt;&lt;BR /&gt;Thank you</description>
      <pubDate>Tue, 07 Apr 2020 14:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638074#M189735</guid>
      <dc:creator>AlexeyS</dc:creator>
      <dc:date>2020-04-07T14:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: find function - negative starting position</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638099#M189740</link>
      <description>&lt;P&gt;Your second description is right.&lt;/P&gt;
&lt;P&gt;Absolute value of POSITION determines where to start the search.&amp;nbsp; SIGN of position determines the direction to search. The result is always location when counting from left, and is always positive. (or zero when not found).&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 15:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-function-negative-starting-position/m-p/638099#M189740</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-07T15:09:46Z</dc:date>
    </item>
  </channel>
</rss>

