<?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 What is the fastest way to search text for matching value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-fastest-way-to-search-text-for-matching-value/m-p/261044#M50719</link>
    <description>&lt;P&gt;I want to search for a list of words in a long text in a column (. If any word in the list exists in the column, the row be in the output dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see my partial code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to search for dog,cat and boat in a column called "Column"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WL = PRXPARSE("/dog|cat|boat/");&lt;/P&gt;&lt;P&gt;do i=1 to N;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; position = PRXMATCH( WL ,Column(i));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if position ge 1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ALERT_TRIGGER_TXT= SUBSTR(Column(i),max(1,position-200),position-1)|| '*' || &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SUBSTR(A_TSC_SUSP_TXT(i),max(1,position),position+200) ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there other text searching function that would make the program faster?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Apr 2016 10:55:56 GMT</pubDate>
    <dc:creator>napat</dc:creator>
    <dc:date>2016-04-04T10:55:56Z</dc:date>
    <item>
      <title>What is the fastest way to search text for matching value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-fastest-way-to-search-text-for-matching-value/m-p/261044#M50719</link>
      <description>&lt;P&gt;I want to search for a list of words in a long text in a column (. If any word in the list exists in the column, the row be in the output dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see my partial code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to search for dog,cat and boat in a column called "Column"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WL = PRXPARSE("/dog|cat|boat/");&lt;/P&gt;&lt;P&gt;do i=1 to N;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; position = PRXMATCH( WL ,Column(i));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if position ge 1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ALERT_TRIGGER_TXT= SUBSTR(Column(i),max(1,position-200),position-1)|| '*' || &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SUBSTR(A_TSC_SUSP_TXT(i),max(1,position),position+200) ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there other text searching function that would make the program faster?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 10:55:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-fastest-way-to-search-text-for-matching-value/m-p/261044#M50719</guid>
      <dc:creator>napat</dc:creator>
      <dc:date>2016-04-04T10:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: What is the fastest way to search text for matching value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-fastest-way-to-search-text-for-matching-value/m-p/261051#M50723</link>
      <description>&lt;P&gt;I would do - without test data (form of a datastep) and required output - :&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  do i="DOG","CAT","BOAT";
    if index(upcase(&amp;lt;your string variable&amp;gt;),i) &amp;gt; 0 then do;
      found=1;
      leave;
    end;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Apr 2016 11:50:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-fastest-way-to-search-text-for-matching-value/m-p/261051#M50723</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-04T11:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: What is the fastest way to search text for matching value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-fastest-way-to-search-text-for-matching-value/m-p/261053#M50725</link>
      <description>&lt;P&gt;&lt;CODE&gt;I guess that you will be mostly I/O bound, but you could try&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list=dog,cat,boat;

data want;
set have;
indicator = 0;
do i = 1 to countw("&amp;amp;list",',');
  if indexw(column,scan("&amp;amp;list",i,',')) &amp;gt; 0 then indicator = 1;
end;
if indicator then output;
drop indicator i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;just to compare runtimes. &lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 11:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-fastest-way-to-search-text-for-matching-value/m-p/261053#M50725</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-04-04T11:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: What is the fastest way to search text for matching value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-fastest-way-to-search-text-for-matching-value/m-p/261054#M50726</link>
      <description>&lt;P&gt;You need to supply data and a complete example program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PRXPARSE is slow and should only be done one time and retain the RC for use in PRXMATCH. &amp;nbsp;See the exampes in the documentation where they use the RETAIN statement and IF _N_ eq 1 THEN ....&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 11:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-fastest-way-to-search-text-for-matching-value/m-p/261054#M50726</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-04-04T11:55:19Z</dc:date>
    </item>
  </channel>
</rss>

