<?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: Matching against multiple keywords in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching-against-multiple-keywords/m-p/684417#M207396</link>
    <description>&lt;P&gt;There is a hash approach that would be best, but this is a simple to understand example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table matches as 
  select name,count(*) as keywords
  from custnm, kwds
  where findw(name,strip(keyword)) &amp;gt; 0
  group by name;
quit;

&lt;/PRE&gt;</description>
    <pubDate>Wed, 16 Sep 2020 22:49:11 GMT</pubDate>
    <dc:creator>CurtisMackWSIPP</dc:creator>
    <dc:date>2020-09-16T22:49:11Z</dc:date>
    <item>
      <title>Matching against multiple keywords</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-against-multiple-keywords/m-p/684396#M207391</link>
      <description>&lt;P&gt;data custnm;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input name $50.;&lt;BR /&gt;datalines;&lt;BR /&gt;ABC AMERICAN REALTY&lt;BR /&gt;ABC MARKETING&lt;BR /&gt;ABC YOGA&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data kwds;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input keyword $15.;&lt;BR /&gt;datalines;&lt;BR /&gt;ABC&lt;BR /&gt;AMERICAN&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;I want to match flag to return 2 since two keyword matched for first record and return 1 for one keyword match.&lt;/P&gt;&lt;P&gt;Let me know if anyone has any solutions around it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 22:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-against-multiple-keywords/m-p/684396#M207391</guid>
      <dc:creator>a_khedekar</dc:creator>
      <dc:date>2020-09-16T22:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Matching against multiple keywords</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-against-multiple-keywords/m-p/684412#M207395</link>
      <description>&lt;P&gt;How many total keywords do you have in your list? There are some approaches that may work for short lists that don't work for longer ones.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should embedded strings "match"? Example: Does keyword "ABC" match value "ABCDE"?&lt;/P&gt;
&lt;P&gt;Are your matches case sensitive? You show everything in upper case but what if you have a value of "Abc". Should that match "ABC" or not.&lt;/P&gt;
&lt;P&gt;What if the same string appears more than once in the value? Would a value of "ABC MARKETING ABC PRODUCTS" have ABC counted as 1 or 2?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 22:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-against-multiple-keywords/m-p/684412#M207395</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-16T22:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Matching against multiple keywords</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-against-multiple-keywords/m-p/684417#M207396</link>
      <description>&lt;P&gt;There is a hash approach that would be best, but this is a simple to understand example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table matches as 
  select name,count(*) as keywords
  from custnm, kwds
  where findw(name,strip(keyword)) &amp;gt; 0
  group by name;
quit;

&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Sep 2020 22:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-against-multiple-keywords/m-p/684417#M207396</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-16T22:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Matching against multiple keywords</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-against-multiple-keywords/m-p/684419#M207398</link>
      <description>&lt;P&gt;Here is a hash solution.&amp;nbsp; Harder to code, but should scale much better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data matches(keep=name keywords);
  if _n_ = 1 then do;
	 declare hash kwds(dataset:"kwds");
	 kwds.defineKey("keyword");
	 kwds.defineDone();
  end;
  set custnm;
  keywords = 0;
  delims = ' ';     
  numWords = countw(name, delims);  /* for each line of text, how many words? */
  do i = 1 to numWords;            /* split text into words */
     keyword = scan(name, i, delims);
     if kwds.check() eq 0 then keywords = keywords + 1;
  end;
run; 
&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Sep 2020 23:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-against-multiple-keywords/m-p/684419#M207398</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-16T23:01:10Z</dc:date>
    </item>
  </channel>
</rss>

