<?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: Index/Find function not working for parsing specific text in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247807#M56341</link>
    <description>&lt;P&gt;Thank you all for the solutions provided! Much appreciated...&lt;/P&gt;
&lt;P&gt;Adding the _ to the index function worked pretty well for my dataset. I am yet to try the code&amp;nbsp;provided ny data_null_ &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Feb 2016 17:48:01 GMT</pubDate>
    <dc:creator>spg</dc:creator>
    <dc:date>2016-02-03T17:48:01Z</dc:date>
    <item>
      <title>Index/Find function not working for parsing specific text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247588#M56317</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When i use the index function to parse the following texts to yield "BAN", both the records are getting a hit, whereas it should ideally be only the first.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, is there a way to specify the code to look for the word BAN after two underscores?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using:&lt;/P&gt;
&lt;P&gt;a=index(TYPE,"BAN");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TYPE&lt;/P&gt;
&lt;P&gt;abcde_DT_BAN_OO_3MORE_LIF_CPM_728x90_abcde&lt;/P&gt;
&lt;P&gt;xyz_ab_RMBAN_PR_BHV_NOGEN_DCPM_160x600_uvwxyz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 19:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247588#M56317</guid>
      <dc:creator>spg</dc:creator>
      <dc:date>2016-02-02T19:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Index/Find function not working for parsing specific text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247606#M56319</link>
      <description>&lt;P&gt;&lt;SPAN&gt;a = index(TYPE, "_BAN_") + 1;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;A much greater flexibility is provided with regular expression pattern matching (e.g. the PRXMATCH function).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 20:03:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247606#M56319</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-02-02T20:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Index/Find function not working for parsing specific text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247610#M56322</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16987"&gt;@spg﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both INDEX and FIND search for substrings, regardless whether they are part of a word. In contrast, the &lt;A href="http://support.sas.com/documentation/cdl/en/syntaxidx/68719/HTML/default/index.htm#/documentation/cdl//en/lefunctionsref/67960/HTML/default/p16rdsa30vmm43n1ej4936nwa01t.htm" target="_blank"&gt;FINDW function&lt;/A&gt;&amp;nbsp;could help you to avoid those unwanted hits:&lt;/P&gt;
&lt;PRE&gt;a=findw(type,'BAN',,'ps');&lt;/PRE&gt;
&lt;P&gt;(The modifiers p and s add punctuation marks [incl. the underscore] and space characters to the list of default delimiters.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Searching for "__BAN" with the INDEX function would, of course, also find this substring in "__BANK". Again, you could try to apply FINDW, but you would have to choose the&amp;nbsp;function arguments&amp;nbsp;carefully. As PG suggested, the final resort might&amp;nbsp;be the PRXMATCH function.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 20:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247610#M56322</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-02T20:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Index/Find function not working for parsing specific text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247614#M56323</link>
      <description>&lt;P&gt;Search for the starting point then FIND from there.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ban;
   input string $80.;
   /*find position of second underscore*/
   s = 0;
   do _n_ = 1 to 2;
      s = findc(string,'_',s+1); 
      end;
   /*Search for BAN*/
   a=find(string,"BAN",s);
   cards;
abBANcde_DT_BAN_OO_3MORE_LIF_CPM_728x90_abcde
xyz_ab_RMBAN_PR_BHV_NOGEN_DCPM_160x600_uvwxyz
one_underscore BAN
No underscore BAN
;;;;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1731i9A2102A379FEB862/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 20:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247614#M56323</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-02T20:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Index/Find function not working for parsing specific text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247620#M56324</link>
      <description>&lt;P&gt;This is a version that uses FINDW to find BAN delimited by UNDERSCORE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ban;
   input string $80.;
   /*find position of second underscore*/
   s = 0;
   do _n_ = 1 to 2;
      s = findc(string,'_',s+1); 
      end;
   /*Search for BAN*/
   a=findw(string,"BAN",s,'_');
   cards;
abBANcde_DT_BAN_OO_3MORE_LIF_CPM_728x90_abcde
xyz_ab_RMBAN_PR_BHV_NOGEN_DCPM_160x600_uvwxyz
one_underscore BAN
No underscore BAN
;;;;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Feb 2016 21:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247620#M56324</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-02T21:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Index/Find function not working for parsing specific text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247807#M56341</link>
      <description>&lt;P&gt;Thank you all for the solutions provided! Much appreciated...&lt;/P&gt;
&lt;P&gt;Adding the _ to the index function worked pretty well for my dataset. I am yet to try the code&amp;nbsp;provided ny data_null_ &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 17:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Index-Find-function-not-working-for-parsing-specific-text/m-p/247807#M56341</guid>
      <dc:creator>spg</dc:creator>
      <dc:date>2016-02-03T17:48:01Z</dc:date>
    </item>
  </channel>
</rss>

