<?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: Finding how many same words exist between two strings. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-how-many-same-words-exist-between-two-strings/m-p/477772#M286245</link>
    <description>&lt;P&gt;You don't need to split the words, you can use the function countw, scan and findw to get the number of same words.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.same_words;
   set work.compged;

   length same i 8;
   drop i;

   same = 0;

   do i = 1 to countw(first_b);
      if findw(first, scan(first_b, i, ' '), ' ', 'sit') then do;
         same = same + 1;
      end;
   end;

   /* FIXME: adjust compged score */

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Jul 2018 05:08:17 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2018-07-13T05:08:17Z</dc:date>
    <item>
      <title>Finding how many same words exist between two strings.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-how-many-same-words-exist-between-two-strings/m-p/477679#M286244</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA COMPONENT;&lt;BR /&gt; infile datalines delimiter=','; &lt;BR /&gt; length FIRST $ 1000 FIRST_B $ 1000;&lt;BR /&gt; INPUT FIRST $ FIRST_B $;&lt;BR /&gt; DATALINES;&lt;BR /&gt; Electric Component keyboard replacement, Keyboard inward component replacement&lt;BR /&gt; Electric Component keyboard replacement, Monitor Component Replacement&lt;BR /&gt; Electric Component keyboard replacement, Mouse component&lt;BR /&gt; Electric Component keyboard replacement, Wire Replacement&lt;BR /&gt; Electric Component keyboard replacement, PIN part&lt;BR /&gt; ;&lt;BR /&gt; &lt;BR /&gt; DATA Compged;&lt;BR /&gt; SET COMPONENT;&lt;BR /&gt; CALL COMPCOST('SWAP=', 5, 'P=', 0, 'INS=', 10,'DEL=',10,'APPEND=',5);&lt;BR /&gt; First_COMPGED=COMPGED(FIRST, FIRST_B, 'iln');&lt;BR /&gt; RUN;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My data is like shown above. To find how many are common words between the two strings I broke down the strings to words in each column.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data split_words;
 set COMPGED;
 delims = ' ,.-!'; 
 array FIRST_B_WORDS[6] $15 FIRST_B1-FIRST_B6;
array FIRST_WORDS[6] $15 FIRST1-FIRST6;
 do i = 1 to 6;
  FIRST_B_WORDS[i] = scan(FIRST_B,i,",- ");
  FIRST_WORDS[i] = scan(FIRST,i,",- ");
  count_words_B=countw(FIRST_B, delims);
  count_words=countw(FIRST, delims);
 end;
 
 drop i delims;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now what I want to do is find how many words are same between&amp;nbsp;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;FIRST_B1-FIRST_B6&amp;nbsp;and FIRST1-FIRST6.&amp;nbsp; &amp;nbsp;Decrease the compged score depending on how many are same between the string&amp;nbsp; to improve the fuzzy logic-compged score to match&amp;nbsp;&lt;/P&gt;&lt;P&gt;as in example Electric Component keyboard replacement to Keyboard inward component replacement&amp;nbsp;&amp;nbsp;as the lowest score suggesting best match.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="st_1.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21764i4B1F19CEDA038C25/image-size/large?v=v2&amp;amp;px=999" role="button" title="st_1.JPG" alt="st_1.JPG" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using&amp;nbsp;SAS EG-7.12&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 20:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-how-many-same-words-exist-between-two-strings/m-p/477679#M286244</guid>
      <dc:creator>Vk_2</dc:creator>
      <dc:date>2018-07-12T20:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Finding how many same words exist between two strings.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-how-many-same-words-exist-between-two-strings/m-p/477772#M286245</link>
      <description>&lt;P&gt;You don't need to split the words, you can use the function countw, scan and findw to get the number of same words.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.same_words;
   set work.compged;

   length same i 8;
   drop i;

   same = 0;

   do i = 1 to countw(first_b);
      if findw(first, scan(first_b, i, ' '), ' ', 'sit') then do;
         same = same + 1;
      end;
   end;

   /* FIXME: adjust compged score */

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jul 2018 05:08:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-how-many-same-words-exist-between-two-strings/m-p/477772#M286245</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-07-13T05:08:17Z</dc:date>
    </item>
  </channel>
</rss>

