<?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: one index function question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301948#M63977</link>
    <description>&lt;P&gt;I'm no great Perl maven, but using prxmatch will give you what you're after. Here's how I did it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_;
infile cards;
retain x "GTTCACTAGCAACCTCAAACAGACACCATGGTGCACCTG";
length pattern $ 9;
input pattern;
match = prxmatch('/' || strip(pattern) || '/', x);
put match=;
cards;
.CCTCA
A.CTCA
AC.TCA
ACC.CA
ACCT.A
ACCTC.
;
run;&lt;/PRE&gt;&lt;P&gt;In Perl, the wild card is '.', not '-'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When this code is run, the pattern is found at position 12 every time. If it weren't found, like with index, it would return 0.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Oct 2016 04:02:04 GMT</pubDate>
    <dc:creator>LaurieF</dc:creator>
    <dc:date>2016-10-03T04:02:04Z</dc:date>
    <item>
      <title>one index function question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301944#M63976</link>
      <description>&lt;P&gt;&amp;nbsp;X=”GTTCACTAGCAACCTCAAACAGACACCATGGTGCACCTG”&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a=”-CCTCA”&lt;/P&gt;&lt;P&gt;b=”A-CTCA”&lt;/P&gt;&lt;P&gt;c=”AC-TCA”&lt;/P&gt;&lt;P&gt;d=”ACC-CA”&lt;/P&gt;&lt;P&gt;e=”ACCT-A”&lt;/P&gt;&lt;P&gt;f=”ACCTC-”&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;“-“ is any one letter, such as “G” “T” or “A”;&lt;/P&gt;&lt;P&gt;I thought a,b,c,d,e,f are all equal to pattern “ACCTCA”&lt;/P&gt;&lt;P&gt;How can I write an index function to find the position of a (or b, or c, or d, or e, or f) in X;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 03:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301944#M63976</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2016-10-03T03:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: one index function question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301948#M63977</link>
      <description>&lt;P&gt;I'm no great Perl maven, but using prxmatch will give you what you're after. Here's how I did it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_;
infile cards;
retain x "GTTCACTAGCAACCTCAAACAGACACCATGGTGCACCTG";
length pattern $ 9;
input pattern;
match = prxmatch('/' || strip(pattern) || '/', x);
put match=;
cards;
.CCTCA
A.CTCA
AC.TCA
ACC.CA
ACCT.A
ACCTC.
;
run;&lt;/PRE&gt;&lt;P&gt;In Perl, the wild card is '.', not '-'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When this code is run, the pattern is found at position 12 every time. If it weren't found, like with index, it would return 0.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 04:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301948#M63977</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2016-10-03T04:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: one index function question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301949#M63978</link>
      <description>&lt;P&gt;find() or index() don't allow for wildcard searches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could either use a Regular Expression or a Like operator in a where clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you just need the first position where one of your patterns matches? And would ALL patterns have to match or only one of them?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 04:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301949#M63978</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-10-03T04:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: one index function question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301958#M63981</link>
      <description>&lt;P&gt;Also, look into COMPGED, Complev and other functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure they'll give you enough control though.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 04:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301958#M63981</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-03T04:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: one index function question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301995#M63989</link>
      <description>&lt;P&gt;Thanks a lot. I never used prxmatch function. I will try it.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 10:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301995#M63989</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2016-10-03T10:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: one index function question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301997#M63990</link>
      <description>&lt;P&gt;&amp;nbsp;X=”GTTCACTAGCAACCTCAAACAGACACCATGGTGCACCTG”&lt;BR /&gt;pattern="ACCTCA" or pattern=&lt;SPAN&gt;"A-CTCA" &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Actually I want to check " if X contains pattern ";&amp;nbsp;&lt;BR /&gt;I found I can not &amp;nbsp;use this&amp;nbsp;logistic judgement,&lt;/P&gt;&lt;P&gt;So I thought maybe I can use index() function,&lt;/P&gt;&lt;P&gt;if result &amp;gt;0 it means X contains pattern;&lt;/P&gt;&lt;P&gt;if result =0 it means X does not contains pattern.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if someone can suggest a better method, it will be great.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 10:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301997#M63990</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2016-10-03T10:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: one index function question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301999#M63991</link>
      <description>&lt;P&gt;You say "pattern" I think RegEx. Below a variation of what has already been proposed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  input string:$60.;
  match_pos= prxmatch('/(.CCTCA|A.CTCA|AC.TCA|ACC.CA|ACCT.A|ACCTC.)/oi',string);
  match_flg= prxmatch('/(.CCTCA|A.CTCA|AC.TCA|ACC.CA|ACCT.A|ACCTC.)/oi',string)&amp;gt;0;
  datalines;
GTTCACTAGCAACCTCAAACAGACACCATGGTGCACCTG
GTTCACTAGCACACTCAAACAGACACCATGGTGCACCTG
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Oct 2016 11:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/301999#M63991</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-10-03T11:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: one index function question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/302033#M63996</link>
      <description>&lt;P&gt;Thanks a lot. It is very helpful.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2016 13:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-index-function-question/m-p/302033#M63996</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2016-10-03T13:11:59Z</dc:date>
    </item>
  </channel>
</rss>

