<?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: PRXmatch and Macro problems in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119446#M24583</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've added 2 changes to your code to make it work with the sample data I've created.&lt;/P&gt;&lt;P&gt;I've added a strip() function around your "words" variables to get rid of leading and trailing blanks and I've added a 'i' to the regular expression to make the search case insensitive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I've got inspired and added a variant which doesn't need macro coding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data SearchTerms;&lt;BR /&gt;&amp;nbsp; infile datalines dsd;&lt;BR /&gt;&amp;nbsp; input words1 $ words2 $;&lt;BR /&gt;&amp;nbsp; datalines;&lt;BR /&gt;word b,word x&lt;BR /&gt;word a,word b&lt;BR /&gt;word z,word a&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; search_term='String with word A and word B in it'; output;&lt;BR /&gt;&amp;nbsp; search_term='String with word B and word A in it'; output;&lt;BR /&gt;&amp;nbsp; search_term='String with word A and word C in it'; output;&lt;BR /&gt;&amp;nbsp; search_term='String with word A in it'; output;&lt;BR /&gt;&amp;nbsp; search_term='String with word B in it'; output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;/* variant 1 with macro code */ &lt;/SPAN&gt; &lt;BR /&gt;data _null_;&lt;BR /&gt;set SearchTerms;&lt;BR /&gt;call symput('word1'||left(_n_),&amp;nbsp; &lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;strip&lt;/STRONG&gt;&lt;/SPAN&gt;(Words1));&lt;BR /&gt;call symput('word2'||left(_n_),&amp;nbsp; &lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;strip&lt;/STRONG&gt;&lt;/SPAN&gt;(Words2));&lt;BR /&gt;CALL SYMPUT( 'TOTOBS' , _N_ );&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%MACRO LOOP;&lt;BR /&gt;data temp;&lt;BR /&gt;set have ;&lt;BR /&gt;%do i=1 %to &amp;amp;TOTOBS;&lt;BR /&gt;&amp;nbsp; if prxmatch("/&amp;amp;&amp;amp;word1&amp;amp;i./&lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;i&lt;/STRONG&gt;&lt;/SPAN&gt;",search_term) gt 0 and &lt;BR /&gt;prxmatch("/&amp;amp;&amp;amp;word2&amp;amp;i./&lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;i&lt;/STRONG&gt;&lt;/SPAN&gt;",search_term) gt 0 then output ;&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%loop;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;/* variant 2 without macro code */&lt;/SPAN&gt;&lt;BR /&gt;data test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then &lt;BR /&gt;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain _prxKey '1';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dcl hash h1(multidata:'y');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h1.defineKey('_prxKey');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h1.defineData('_prxID');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h1.defineDone();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do _i=1 to nobs;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set SearchTerms(keep=words1 words2) nobs=nobs point=_i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _prxID=prxparse(cats('/(?=.*',words1,')(?=.*',words2,')/i'));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h1.add();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop _: words:;&lt;BR /&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _rc=h1.find();&lt;BR /&gt;&amp;nbsp; do while(_rc=0);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prxmatch(_prxID,search_term) then output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h1.find_next();&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 28 Jul 2012 04:11:36 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2012-07-28T04:11:36Z</dc:date>
    <item>
      <title>PRXmatch and Macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119441#M24578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to everyone who has helped! I revised my code but see that the issue is with my PRXmatch not reading as I want it.&amp;nbsp; I am a novice PRXmatch coder and my macro skills are ok.&lt;/P&gt;&lt;P&gt; Its definitely my logic with the PRXmatch.&lt;SPAN style="font-family: Courier New; color: #800080;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; color: #800080;"&gt;My PRXmatch "AND statement" does not read in both macro variables. &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; color: #800080;"&gt;Any help would be appreciated!!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; jessica.TwoWords_&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; font-size: 10pt;"&gt;BeginMonth.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; symput(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; font-size: 10pt;"&gt;'word1'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;||left(_n_),&amp;nbsp; Words1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; symput(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; font-size: 10pt;"&gt;'word2'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;||left(_n_),&amp;nbsp; Words2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;CALL&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; SYMPUT( &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; font-size: 10pt;"&gt;'TOTOBS'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; , _N_ );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;/*Runing prxmatch for word groupings*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;/*This looks at user defined particular words in the string*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: green; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; font-family: 'Courier New';"&gt;%MACRO&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; &lt;STRONG&gt;&lt;EM&gt;LOOP&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;data temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;set jessica.PercentImp_&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; font-size: 10pt;"&gt;BeginMonth.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; font-size: 10pt;"&gt;EndMonth.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;%to&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; &amp;amp;TOTOBS;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;&amp;nbsp; if prxmatch(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; font-size: 10pt;"&gt;"/&amp;amp;&amp;amp;word1&amp;amp;i./"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;,search_term) gt &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; and &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; prxmatch(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; font-size: 10pt;"&gt;"/&amp;amp;&amp;amp;word2&amp;amp;i./"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;,search_term) gt &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; then output ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;loop;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 22:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119441#M24578</guid>
      <dc:creator>guillory21</dc:creator>
      <dc:date>2012-07-26T22:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: PRXmatch and Macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119442#M24579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried &amp;amp;&amp;amp;word1&amp;amp;i without the trailing "."? I've seen some instances where the trailing period causes logic to fail.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 23:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119442#M24579</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-07-26T23:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: PRXmatch and Macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119443#M24580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please post the two files.&amp;nbsp; Your first data _null_ statement has me questioning what&lt;/P&gt;&lt;P&gt;jessica.TwoWords_&amp;amp;&lt;SPAN style="color: teal; font-family: 'Courier New'; font-size: 10pt;"&gt;BeginMonth.&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;; looks like.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;Art&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 23:01:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119443#M24580</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-07-26T23:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: PRXmatch and Macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119444#M24581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Your code looks fine, so like Art said, sample data will be needed to do the trouble shooting. One small suggestion to improve your efficiency:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;CALL&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; SYMPUT( &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; font-size: 10pt;"&gt;'TOTOBS'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt; , _N_ );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;You probably already realize that you are refreshing macro variable 'totobs' n times, if you have multimillion records, that would result in significant amount of waste. Try to use nobs= or end=last + if last to avoid it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; font-size: 10pt;"&gt;Haikuo&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jul 2012 03:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119444#M24581</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-07-27T03:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: PRXmatch and Macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119445#M24582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;another suggestion :&lt;/P&gt;&lt;P&gt;use call SYMPUTX() instead of call SYMPUT()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;because it will remove leading/trailing blanks from the value in _N_&lt;/P&gt;&lt;P&gt;Not only leading blanks can be a problem, trailing blanks will affect you too in&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: purple; font-family: 'Courier New'; font-size: 10pt;"&gt;"/&amp;amp;&amp;amp;word1&amp;amp;i./"&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jul 2012 20:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119445#M24582</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2012-07-27T20:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: PRXmatch and Macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119446#M24583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've added 2 changes to your code to make it work with the sample data I've created.&lt;/P&gt;&lt;P&gt;I've added a strip() function around your "words" variables to get rid of leading and trailing blanks and I've added a 'i' to the regular expression to make the search case insensitive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I've got inspired and added a variant which doesn't need macro coding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data SearchTerms;&lt;BR /&gt;&amp;nbsp; infile datalines dsd;&lt;BR /&gt;&amp;nbsp; input words1 $ words2 $;&lt;BR /&gt;&amp;nbsp; datalines;&lt;BR /&gt;word b,word x&lt;BR /&gt;word a,word b&lt;BR /&gt;word z,word a&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; search_term='String with word A and word B in it'; output;&lt;BR /&gt;&amp;nbsp; search_term='String with word B and word A in it'; output;&lt;BR /&gt;&amp;nbsp; search_term='String with word A and word C in it'; output;&lt;BR /&gt;&amp;nbsp; search_term='String with word A in it'; output;&lt;BR /&gt;&amp;nbsp; search_term='String with word B in it'; output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;/* variant 1 with macro code */ &lt;/SPAN&gt; &lt;BR /&gt;data _null_;&lt;BR /&gt;set SearchTerms;&lt;BR /&gt;call symput('word1'||left(_n_),&amp;nbsp; &lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;strip&lt;/STRONG&gt;&lt;/SPAN&gt;(Words1));&lt;BR /&gt;call symput('word2'||left(_n_),&amp;nbsp; &lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;strip&lt;/STRONG&gt;&lt;/SPAN&gt;(Words2));&lt;BR /&gt;CALL SYMPUT( 'TOTOBS' , _N_ );&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%MACRO LOOP;&lt;BR /&gt;data temp;&lt;BR /&gt;set have ;&lt;BR /&gt;%do i=1 %to &amp;amp;TOTOBS;&lt;BR /&gt;&amp;nbsp; if prxmatch("/&amp;amp;&amp;amp;word1&amp;amp;i./&lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;i&lt;/STRONG&gt;&lt;/SPAN&gt;",search_term) gt 0 and &lt;BR /&gt;prxmatch("/&amp;amp;&amp;amp;word2&amp;amp;i./&lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;i&lt;/STRONG&gt;&lt;/SPAN&gt;",search_term) gt 0 then output ;&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%loop;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;/* variant 2 without macro code */&lt;/SPAN&gt;&lt;BR /&gt;data test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then &lt;BR /&gt;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain _prxKey '1';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dcl hash h1(multidata:'y');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h1.defineKey('_prxKey');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h1.defineData('_prxID');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h1.defineDone();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do _i=1 to nobs;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set SearchTerms(keep=words1 words2) nobs=nobs point=_i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _prxID=prxparse(cats('/(?=.*',words1,')(?=.*',words2,')/i'));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h1.add();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop _: words:;&lt;BR /&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _rc=h1.find();&lt;BR /&gt;&amp;nbsp; do while(_rc=0);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prxmatch(_prxID,search_term) then output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h1.find_next();&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jul 2012 04:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119446#M24583</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-07-28T04:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: PRXmatch and Macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119447#M24584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Doesn't look like a problem that needs either macro logic or prxmatch function.&amp;nbsp; Indexw function should work fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; set jessica.PercentImp_&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: teal;"&gt;BeginMonth.&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: teal;"&gt;EndMonth&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; found=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; do i=1 to nobs while (not found);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;jessica.TwoWords_&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: teal;"&gt;BeginMonth&lt;/SPAN&gt;&lt;SPAN style="color: #000000; font-size: 10pt; font-family: 'Courier New';"&gt; nobs=nobs point=i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; found=indexw(search_term,trim(words1)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and indexw(search_term,trim(words2))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; if found then output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jul 2012 19:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119447#M24584</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-07-28T19:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: PRXmatch and Macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119448#M24585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you're using prxmatch then the "words" could also be RegEx expressions. Or one could just allow for wildcards in the "words" and then translate these wildcards into a corresponding RegEx expression.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Jul 2012 00:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119448#M24585</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-07-29T00:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: PRXmatch and Macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119449#M24586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I usually find it a lot easier to debug generated code when I use a data step to write the code to file.&amp;nbsp; Then you can look at the file and make sure the syntax is correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: navy;"&gt;filename code temp;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;STRONG style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: navy;"&gt;data&lt;/STRONG&gt; &lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;&amp;nbsp; set&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; jessica.TwoWords_&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: teal;"&gt;BeginMonth. end=eof&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp; if _n_=1 then put 'if ' @;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp; else put 'or ' @ ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp; put "(&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;prxmatch('" words1 +(-1) "'&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;,search_term) "&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "and &lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;prxmatch('" &lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: purple;"&gt;words2 +(-1) "'&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;,search_term))"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp; if eof then put '&amp;nbsp; then output' / ';' ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 10pt; font-style: inherit;"&gt;data temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp; set jessica.PercentImp_&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: teal;"&gt;BeginMonth.&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: teal;"&gt;EndMonth.&lt;/SPAN&gt;&lt;SPAN style="font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 10pt; font-style: inherit;"&gt;&amp;nbsp; %inc code / source2 ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 10pt; font-style: inherit;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Jul 2012 04:19:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119449#M24586</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-07-29T04:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: PRXmatch and Macro problems</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119450#M24587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agree.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Jul 2012 07:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXmatch-and-Macro-problems/m-p/119450#M24587</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-07-29T07:07:56Z</dc:date>
    </item>
  </channel>
</rss>

