<?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 Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PRXMATCH-Macro/m-p/560958#M156957</link>
    <description>&lt;P&gt;I don't understand why you are taking the values out of the dataset into macro variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can generate the string with the regular expression using normal code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide example input data set(s) and expected output data.&lt;/P&gt;
&lt;P&gt;Also explain (in words) the algorithm you think will be able to produce that output.&lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2019 19:52:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-05-22T19:52:51Z</dc:date>
    <item>
      <title>PRXMATCH Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXMATCH-Macro/m-p/560936#M156949</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm attempting to troubleshoot some code and having no success. Ideally I would have this pull&amp;nbsp;search terms&amp;nbsp;from an excel table to be then used in a PRXMATCH statement which searches row by row for these terms, flagging them if they appear. This works well other than the fact that any modifiers or metacharacters entered in the excel document (which are then inserted into the PRXMATCH statement) are ignored for some reason.&lt;/P&gt;&lt;P&gt;Essentially I'd like to have a program that runs through datasets searching for words/phrases that are found in another document, but adding this intermediary seems to cause odd behavior.&lt;/P&gt;&lt;P&gt;The data I'm dealing with is product descriptions and so it would be useful to change entries in an excel file (say, searching for men's clothes would mean the column is populated with terms like "man" "men's" "boys") and have a variable created and instances where these terms appear be flagged. This instance in particular worked, but if I'm looking for terms such as "fire-proof" I would normally use regex along the lines of "fire\sproof". This does not work, however and these instances aren't flagged when they should be.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO TEMP; 
%DO i = 1 %TO &amp;amp;MAX_VARNUM.;
	data rep1; set out.clean_list (keep = &amp;amp;&amp;amp;V_&amp;amp;i. where= (&amp;amp;&amp;amp;V_&amp;amp;i. ne "")); run; 
	proc sql; 
	select &amp;amp;&amp;amp;V_&amp;amp;i.
	INTO :&amp;amp;&amp;amp;V_&amp;amp;i. SEPARATED BY  '|'
		from rep1
	;quit; 
	proc sql; create table macros&amp;amp;i. as select * from dictionary.macros; quit;
%END;

DATA cln (KEEP = n_id all_txt ); set &amp;amp;out_lib..complete; n_id = _n_; run;
	%DO i = 1 %TO &amp;amp;MAX_VARNUM.;

%LET VN_&amp;amp;i. = %SYSFUNC(TRANSLATE(&amp;amp;&amp;amp;V_&amp;amp;i., "__", " -")); 

DATA cln_&amp;amp;i. ; SET cln;

IF  PRXMATCH("m/(&amp;amp;&amp;amp;V_&amp;amp;i.)/oi", all_txt) then
						DO;
						name_&amp;amp;&amp;amp;VN_&amp;amp;i. = "&amp;amp;&amp;amp;V_&amp;amp;i."; 	

						&amp;amp;&amp;amp;VN_&amp;amp;i. = 1; 	
					END; 	
			RUN;	
	%END;

DATA fnl.clnw_&amp;amp;inpdet._&amp;amp;date.; 
MERGE  out.complete cln_:; 
	BY n_id;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 18:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXMATCH-Macro/m-p/560936#M156949</guid>
      <dc:creator>gio_sulli</dc:creator>
      <dc:date>2019-05-22T18:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: PRXMATCH Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXMATCH-Macro/m-p/560958#M156957</link>
      <description>&lt;P&gt;I don't understand why you are taking the values out of the dataset into macro variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can generate the string with the regular expression using normal code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide example input data set(s) and expected output data.&lt;/P&gt;
&lt;P&gt;Also explain (in words) the algorithm you think will be able to produce that output.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 19:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXMATCH-Macro/m-p/560958#M156957</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-22T19:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: PRXMATCH Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXMATCH-Macro/m-p/560991#M156977</link>
      <description>&lt;P&gt;Probably not your exact need, but since you did not supply examples of you data structure, this will do.&lt;/P&gt;
&lt;P&gt;No macros needed, this matches the values you describe:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data CLEAN_LIST;
  VARA='mens ' ; VARB='fire-proof'; output;
  VARA='boys ' ; VARB='man       '; output;
run;
data HAVE;
  ALL_TXT='fireproof vest'; output;
  ALL_TXT="boy's vest";     output;
run;  
data MATCH;
  set HAVE;
  if 0 then set CLEAN_LIST nobs=NOBS;
  do VAR='VARA', 'VARB';
    do OBSNO=1 to NOBS;
      set CLEAN_LIST point=OBSNO;
      VAL1 =vvaluex(VAR);
      VAL2 =prxchange('s/[^A-Z]/[^A-Z]?/i', -1, trim(VAL1)); 
      FLAG=prxmatch(catt('m/',VAL2,'/i'), ALL_TXT);
      if FLAG then output;
    end;
  end;
  keep ALL_TXT VAL1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.MATCH" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;ALL_TXT&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;VAL1&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;fireproof vest&lt;/TD&gt;
&lt;TD class="l data"&gt;fire-proof&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 23:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXMATCH-Macro/m-p/560991#M156977</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-05-22T23:59:36Z</dc:date>
    </item>
  </channel>
</rss>

