<?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: PRX match on string but excluding substring in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693847#M211582</link>
    <description>&lt;P&gt;Yes!&amp;nbsp; That works for the criteria I listed.&amp;nbsp; I forgot to include one more though, "END OF LIFE" by itself without any characters or space before or after.&amp;nbsp; This should match as well but doesn't using the regular expression you wrote.&amp;nbsp; Can this be modified to include this as well?&lt;/P&gt;</description>
    <pubDate>Fri, 23 Oct 2020 16:53:16 GMT</pubDate>
    <dc:creator>Ryanb2</dc:creator>
    <dc:date>2020-10-23T16:53:16Z</dc:date>
    <item>
      <title>PRX match on string but excluding substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693803#M211579</link>
      <description>&lt;P&gt;I'm using prxmatch to match the string "END OF LIFE" but I don't want that string to match if it is followed by " CARE".&amp;nbsp; However, I can't seem to get the regular expression right (see below).&amp;nbsp; I could find lots of examples for excluding single characters but not for strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The regular expression should not match on&amp;nbsp;"END OF LIFE CARE", but should match on&amp;nbsp;"END OF LIFE MEDICATIONS" and&amp;nbsp;"END OF LIFE OPTION" and "NEAR END OF LIFE OPTION"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data out;&lt;BR /&gt;set in;&lt;/P&gt;
&lt;P&gt;if prxmatch('/(END OF LIFE[^( CARE)])/i',strip(string)) then output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2020 16:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693803#M211579</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2020-10-23T16:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: PRX match on string but excluding substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693839#M211580</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input str $50.;
cards;
END OF LIFE CARE
END OF LIFE MEDICATIONS
END OF LIFE OPTION
NEAR END OF LIFE OPTION
;


data want;
 set have;
 if prxmatch('/END OF LIFE\s\b(?:(?!CARE)\w)+\b/', str);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Oct 2020 16:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693839#M211580</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-23T16:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: PRX match on string but excluding substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693842#M211581</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use &lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p00ab6ey29t2i8n1ihel88tqtga9.htm&amp;amp;locale=en" target="_self"&gt;find() function&lt;/A&gt; to achieve this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
   infile datalines truncover;
   input STRING $500.;
   datalines;
END OF LIFE CARE
END OF LIFE MEDICATIONS
END OF LIFE OPTION
NEAR END OF LIFE OPTION
SOMETHING ELSE
;

data WANT;
   set HAVE;
   if find(string,'END OF LIFE') and not find(string,'END OF LIFE CARE');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2020 16:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693842#M211581</guid>
      <dc:creator>LeonidBatkhan</dc:creator>
      <dc:date>2020-10-23T16:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: PRX match on string but excluding substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693847#M211582</link>
      <description>&lt;P&gt;Yes!&amp;nbsp; That works for the criteria I listed.&amp;nbsp; I forgot to include one more though, "END OF LIFE" by itself without any characters or space before or after.&amp;nbsp; This should match as well but doesn't using the regular expression you wrote.&amp;nbsp; Can this be modified to include this as well?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2020 16:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693847#M211582</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2020-10-23T16:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: PRX match on string but excluding substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693848#M211583</link>
      <description>&lt;P&gt;Thanks for your response.&amp;nbsp; I considered doing something like this, but I simplified my code greatly in this post.&amp;nbsp; I need to match on far more strings and for many more fields in a SQL statement.&amp;nbsp; I will likely need to exclude more strings as well.&amp;nbsp; If I was working in a data step I might write something like this and then process all the columns in an array, but I'm looking for a regular expression solution.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2020 16:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693848#M211583</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2020-10-23T16:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: PRX match on string but excluding substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693849#M211584</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/46197"&gt;@Ryanb2&lt;/a&gt;&amp;nbsp; Please try this-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input str $50.;
cards;
CARE
END OF LIFE CARE
END OF LIFE MEDICATIONS
END OF LIFE OPTION
NEAR END OF LIFE OPTION
END OF LIFE CARE jbjbj
jgjhbjhb
END OF LIFE
;
data want;
 set have;
 if prxmatch('/^END OF LIFE$|END OF LIFE\s\b(?:(?!CARE)\w)+\b/', strip(str));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Oct 2020 17:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693849#M211584</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-23T17:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: PRX match on string but excluding substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693852#M211585</link>
      <description>&lt;P&gt;That worked!&amp;nbsp; Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's frustrating the solution is not simpler.&amp;nbsp; It seems logical and practical that strings to exclude could be contained in parentheses like in my example code.&amp;nbsp; It would make it a lot easier to add more strings to exclude if testing showed more were needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Much appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2020 17:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693852#M211585</guid>
      <dc:creator>Ryanb2</dc:creator>
      <dc:date>2020-10-23T17:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: PRX match on string but excluding substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693853#M211586</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/46197"&gt;@Ryanb2&lt;/a&gt;&amp;nbsp; Personally, I am glad SAS (my only religion) is rather vast and hopefully(complex) for I would always have something new to learn. Believing I have some real youth left and can have reasonably good mental and physical health(including my immediate family) with reasonable economic conditions over the next 25+ years, I would love and want to master ins and outs of SAS in its entirety.&amp;nbsp; Peace!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2020 17:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRX-match-on-string-but-excluding-substring/m-p/693853#M211586</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-23T17:22:00Z</dc:date>
    </item>
  </channel>
</rss>

