<?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 Prxmatch condition? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370562#M65108</link>
    <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use 'Prxmatch' to search the strings below.&amp;nbsp;&amp;nbsp; I found the 'I' is for 'or' condition.&amp;nbsp; Is there a way could do in the 'and' condition?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; datain;&lt;/P&gt;&lt;P&gt;format name $ &lt;STRONG&gt;500.&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;input name &amp;amp;;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;John__If_True_kary&lt;/P&gt;&lt;P&gt;John_If_True__Mary&lt;/P&gt;&lt;P&gt;John__If_True1_kary&lt;/P&gt;&lt;P&gt;John_If_True_kary&lt;/P&gt;&lt;P&gt;Tom__If_Not__Carol&lt;/P&gt;&lt;P&gt;Tom__If_Not_Carol&lt;/P&gt;&lt;P&gt;Tom_If_Not1_Carol&lt;/P&gt;&lt;P&gt;Joe__If_True___Jane&lt;/P&gt;&lt;P&gt;Joe__If_False_Jane&lt;/P&gt;&lt;P&gt;Joe__If_False__Paul1&lt;/P&gt;&lt;P&gt;Joe__If_False___Jane&lt;/P&gt;&lt;P&gt;Paul_If_False2__Jane&lt;/P&gt;&lt;P&gt;Joe__If_False2___Jane&lt;/P&gt;&lt;P&gt;Joe___If_False__Jane&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; dataout;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set datain;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prxmatch("m/If_True|mary/i",name) &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; then found=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if prxmatch("m/If_True|kary/i",name) &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; then found=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if prxmatch("m/If_False|Jane/i",name) &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; then found=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if prxmatch("m/If_False|paul/i",name) &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; then found=&lt;STRONG&gt;4&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if prxmatch("m/If_Not|Carol/i",name) &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; then found=&lt;STRONG&gt;5&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else found=&lt;STRONG&gt;0&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result I am looking for is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if index(lowcase(name),' If_True &lt;SPAN&gt;') &amp;gt; 0 and&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;index(lowcase(name),' mary &lt;SPAN&gt;') &amp;gt; 0 and&lt;/SPAN&gt;&amp;nbsp; index(lowcase(name),' John &lt;SPAN&gt;') &amp;gt; 0 then found = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else found=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jun 2017 13:39:17 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2017-06-26T13:39:17Z</dc:date>
    <item>
      <title>Prxmatch condition?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370562#M65108</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use 'Prxmatch' to search the strings below.&amp;nbsp;&amp;nbsp; I found the 'I' is for 'or' condition.&amp;nbsp; Is there a way could do in the 'and' condition?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; datain;&lt;/P&gt;&lt;P&gt;format name $ &lt;STRONG&gt;500.&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;input name &amp;amp;;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;John__If_True_kary&lt;/P&gt;&lt;P&gt;John_If_True__Mary&lt;/P&gt;&lt;P&gt;John__If_True1_kary&lt;/P&gt;&lt;P&gt;John_If_True_kary&lt;/P&gt;&lt;P&gt;Tom__If_Not__Carol&lt;/P&gt;&lt;P&gt;Tom__If_Not_Carol&lt;/P&gt;&lt;P&gt;Tom_If_Not1_Carol&lt;/P&gt;&lt;P&gt;Joe__If_True___Jane&lt;/P&gt;&lt;P&gt;Joe__If_False_Jane&lt;/P&gt;&lt;P&gt;Joe__If_False__Paul1&lt;/P&gt;&lt;P&gt;Joe__If_False___Jane&lt;/P&gt;&lt;P&gt;Paul_If_False2__Jane&lt;/P&gt;&lt;P&gt;Joe__If_False2___Jane&lt;/P&gt;&lt;P&gt;Joe___If_False__Jane&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; dataout;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set datain;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prxmatch("m/If_True|mary/i",name) &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; then found=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if prxmatch("m/If_True|kary/i",name) &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; then found=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if prxmatch("m/If_False|Jane/i",name) &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; then found=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if prxmatch("m/If_False|paul/i",name) &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; then found=&lt;STRONG&gt;4&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if prxmatch("m/If_Not|Carol/i",name) &amp;gt; &lt;STRONG&gt;0&lt;/STRONG&gt; then found=&lt;STRONG&gt;5&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else found=&lt;STRONG&gt;0&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result I am looking for is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if index(lowcase(name),' If_True &lt;SPAN&gt;') &amp;gt; 0 and&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;index(lowcase(name),' mary &lt;SPAN&gt;') &amp;gt; 0 and&lt;/SPAN&gt;&amp;nbsp; index(lowcase(name),' John &lt;SPAN&gt;') &amp;gt; 0 then found = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else found=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 13:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370562#M65108</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-26T13:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch condition?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370573#M65109</link>
      <description>&lt;P&gt;something like this&lt;/P&gt;
&lt;PRE&gt;data dataout;

      set datain;

      if prxmatch("m/^John.*If_True.*mary$/i",trim(name)) &amp;gt; 0 then found=1;

      else found = 0;

run;

quit;
&lt;/PRE&gt;
&lt;P&gt;if john is no exactly at begining then use .* instead of ^ and if mary is not exactly at the end then replace $ with .* . Please remmeber order of values is important&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 13:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370573#M65109</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-26T13:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch condition?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370585#M65111</link>
      <description>&lt;P&gt;If the order of the values isn't relevant you could use something like:&lt;/P&gt;
&lt;PRE&gt;data dataout;
  set datain;
  if prxmatch("m/(?=.*?If_True)(?=.*?mary)/i",name) &amp;gt; 0 then found=1;
  else if prxmatch("m/(?=.*?If_True)(?=.*?kary)/i",name) &amp;gt; 0 then found=2;
  else if prxmatch("m/(?=.*?If_False)(?=.*?Jane)/i",name) &amp;gt; 0 then found=3;
  else if prxmatch("m/(?=.*?If_False)(?=.*?paul)/i",name) &amp;gt; 0 then found=4;
  else if prxmatch("m/(?=.*?If_Not)(?=.*?Carol)/i",name) &amp;gt; 0 then found=5;
  else found=0;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 14:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370585#M65111</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-06-26T14:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch condition?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370601#M65112</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a passionate user and defender of regular expressions but I think you are missusing them by using them in this context and increasing your program complexity without any gain.&lt;/P&gt;&lt;P&gt;I think you would be better advised to split the 'name' string into several variables and adapt your logic in accordance. It would be much easier for you to review and debug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA Datain2;
   set datain;
   length firstname1 condition firstname2 $200;
   firstname1=scan(name,1,'_');
   condition=scan(name,2,'_')||'_'||scan(name,3,'_'); 
   firstname2=scan(name,4,'_'); 

   if firstname1 eq '...' AND/OR .... then found=...;
   else if ....;
RUN;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Jun 2017 14:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370601#M65112</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2017-06-26T14:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch condition?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370613#M65114</link>
      <description>&lt;P&gt;Thank you so much for all of your kind help.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 14:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Prxmatch-condition/m-p/370613#M65114</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-26T14:37:11Z</dc:date>
    </item>
  </channel>
</rss>

