<?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: Using PCRXFIND with DS2 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476532#M122651</link>
    <description>&lt;P&gt;"and because prxmatch is not working correctly." - can you explain this? Never had any problems with prxmatch as long as I used trim on the second argument.&lt;/P&gt;</description>
    <pubDate>Mon, 09 Jul 2018 17:15:16 GMT</pubDate>
    <dc:creator>error_prone</dc:creator>
    <dc:date>2018-07-09T17:15:16Z</dc:date>
    <item>
      <title>Using PCRXFIND with DS2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476531#M122650</link>
      <description>&lt;P&gt;I want to replicate this using PCRXFIND instead of prxmatch for speed and because prxmatch is not working correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expect the following to match and I want the code to use PCRXFIND not prxmatch.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;John Sales
Mary Acctng                 Act
Joe Findme                  Findme
Sue Hereiam                 Hereiam&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to find text in a data file.&amp;nbsp; Here is a reproducible example.&amp;nbsp; There is one file with the data to search and another with the search terms.&amp;nbsp; I want to use regular expressions.&amp;nbsp; Normally this is&amp;nbsp;done with prxmatch.&amp;nbsp; I want to do it with PCRXFIND because I am working inside DS2.&amp;nbsp; I use a hash iterator to iterate through the search terms or each observation in the data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The search result do not follow any pattern I can recognize.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;* ds2 PCRXFIND example;

data person;
	input name $ dept $;
	datalines;
John Sales
Mary Acctng
Joe Findme
Sue Hereiam
;
run;


data searchterms;
	infile datalines missover;
	input s_index $ term $;
datalines;
1	Hereiam
2	Findme
3   Acc
;
run;

proc contents data=searchterms; run;
proc print data=searchterms; run;

proc ds2;
	data search_results (overwrite=yes);
	
	dcl double rc c ;
	declare char(8) s_index;
	declare char(8) term;
	declare char(11) name dept;
	declare char(1) c_options;
	declare char(20) search_term search_text;
	dcl package hash h(1, '{select s_index, term from searchterms}');
	dcl package hiter hi('h');
		method init();
			c_options = 'i';
			rc = h.defineKey('s_index');
			rc = h.defineData('term');
			rc = h.defineDone();
		end;
		method run();
			dcl double rc;
			set {select  name, dept from person};
			rc = hi.first();
			do while(rc=0);
				c = prxmatch('/'||compress(term)||'/i',name||'   '||dept);
				search_term = '/'||compress(term)||'/i';
				search_text = name||'   '||dept;
				rc = hi.next();
				output;

			end;
		end;
	enddata;
run;
quit;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 21:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476531#M122650</guid>
      <dc:creator>harlananelson</dc:creator>
      <dc:date>2018-07-09T21:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using PCRXFIND with DS2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476532#M122651</link>
      <description>&lt;P&gt;"and because prxmatch is not working correctly." - can you explain this? Never had any problems with prxmatch as long as I used trim on the second argument.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 17:15:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476532#M122651</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-07-09T17:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using PCRXFIND with DS2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476533#M122652</link>
      <description>&lt;P&gt;If you run the code I posted, the matched lines&amp;nbsp;don't correspond to the search terms.&amp;nbsp; I save the search terms in the data set and it is clear I don't need the trim the second term. But I never trim the&amp;nbsp;string to be searched (second term).&amp;nbsp; Sometimes I trim the search term (first term).&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 17:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476533#M122652</guid>
      <dc:creator>harlananelson</dc:creator>
      <dc:date>2018-07-09T17:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using PCRXFIND with DS2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476622#M122673</link>
      <description>&lt;P&gt;Perhaps it would help to show what you expect or desire&amp;nbsp;to see given that example data.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 21:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476622#M122673</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-09T21:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using PCRXFIND with DS2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476624#M122674</link>
      <description>&lt;P&gt;Ok, I made that more explicit.&amp;nbsp; I want the solution to use PCRXFIND.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 21:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-PCRXFIND-with-DS2/m-p/476624#M122674</guid>
      <dc:creator>harlananelson</dc:creator>
      <dc:date>2018-07-09T21:57:50Z</dc:date>
    </item>
  </channel>
</rss>

