<?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/Removing the exact duplicate word using FIND(W) function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615892#M180207</link>
    <description>&lt;P&gt;I didn't see anything wrong in output if you are using FINDW().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want(keep=string newstring);
   set have;
   newstring=scan(string, 1, ' ');
   do i=2 to countw(string,' ');
      word=scan(string, i, ' ');
     /* found=find(newstring, word, 'it');  */ 
	  found=findw(newstring, word, 'it');
      if found=0 then newstring=catx(' ', newstring, word);
   end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Jan 2020 11:27:15 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2020-01-08T11:27:15Z</dc:date>
    <item>
      <title>Matching/Removing the exact duplicate word using FIND(W) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615853#M180180</link>
      <description>&lt;P&gt;I have duplicate words in a string which mimics other words with a minor differences in characters. But while identifying them using FIND/FINDW function it is considering both as same words and removing them.For example &lt;STRONG&gt;JAPAN and JAPANESE&lt;/STRONG&gt; are both distinct words present in the same string , when trying to identify them using &lt;STRONG&gt;FIND/FINDW&lt;/STRONG&gt; function both considered as same word and deleting one of them, but ideally both of them are different words. Same for &lt;STRONG&gt;FATEST and FATESTCD.&lt;/STRONG&gt;How to identify the exact match to remove the duplicate words using FIND/FINDw or PRXMATCH functions&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input string :$200.;
infile datalines dlm=',';
datalines;
apple orange kiwi apple grapes strawberry peach kiwi peach
China USA UK Australia Japanese USA UK Australian Japan Chinase
FOOTBALL BasketBall basketball Hockey football
FACAT FATESTCD FATEST FAOBJ STDT STDTC VISIT VISITNUM
;

data want(keep=string newstring);
   set have;
   newstring=scan(string, 1, ' ');
   do i=2 to countw(string,' ');
      word=scan(string, i, ' ');
      found=find(newstring, word, 'it');   
/*	  fnd=findw(newstring, word, 'it');*/
      if found=0 then newstring=catx(' ', newstring, word);
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 04:59:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615853#M180180</guid>
      <dc:creator>keen_sas</dc:creator>
      <dc:date>2020-01-08T04:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Matching/Removing the exact duplicate word using FIND(W) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615855#M180182</link>
      <description>&lt;P&gt;Maybe it is to early for my brain, but what do expect as result?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 06:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615855#M180182</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-01-08T06:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Matching/Removing the exact duplicate word using FIND(W) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615857#M180183</link>
      <description>&lt;P&gt;This is my favorite document on prxmatch and other perl expression SAS functions:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf" target="_blank" rel="noopener"&gt;https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use this all of the time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take a look!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 06:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615857#M180183</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2020-01-08T06:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Matching/Removing the exact duplicate word using FIND(W) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615861#M180186</link>
      <description>&lt;P&gt;Current Output&lt;/P&gt;
&lt;PRE&gt;newstring
apple orange kiwi grapes strawberry peach
China USA UK Australia Japanese Australian Chinase------&amp;gt; &lt;STRONG&gt;JAPAN is deleted here,though it is unique word&lt;/STRONG&gt;
FOOTBALL BasketBall Hockey
FACAT FATESTCD FAOBJ STDT STDTC VISIT VISITNUM----&amp;gt;&lt;STRONG&gt;FATEST is deleted here,though it is unique word
&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;Expected output:&lt;/P&gt;
&lt;PRE&gt;apple orange kiwi grapes strawberry peach
China USA UK Australia Japanese Australian Japan Chinase
FOOTBALL BasketBall Hockey
FACAT FATESTCD FATEST FAOBJ STDT STDTC VISIT VISITNUM 
&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2020 07:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615861#M180186</guid>
      <dc:creator>keen_sas</dc:creator>
      <dc:date>2020-01-08T07:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Matching/Removing the exact duplicate word using FIND(W) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615863#M180188</link>
      <description>&lt;P&gt;The third argument of findw is the list of separating chars, you can't skip that parameter if you want to use the options-parameter. So try&lt;/P&gt;
&lt;P&gt;found = findw(newstring, word, ' ', 'sit');&lt;/P&gt;
&lt;P&gt;The option S had to be added, because T affects the third parameter, too.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 07:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615863#M180188</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-01-08T07:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Matching/Removing the exact duplicate word using FIND(W) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615872#M180194</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16518"&gt;@keen_sas&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not see any issue in your program. You may add lengths for newstring and word.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code I tried which seem to give what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(keep=string newstring);
   set have;
   length word $30 newstring $200;
   newstring=scan(string, 1, ' ');
   do i=2 to countw(string,' ');
      word=scan(string, i, ' ');
      found=find(newstring, word, 'it');   
      if found=0 then newstring=catx(' ', newstring, word);
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2020 09:36:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615872#M180194</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2020-01-08T09:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Matching/Removing the exact duplicate word using FIND(W) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615892#M180207</link>
      <description>&lt;P&gt;I didn't see anything wrong in output if you are using FINDW().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want(keep=string newstring);
   set have;
   newstring=scan(string, 1, ' ');
   do i=2 to countw(string,' ');
      word=scan(string, i, ' ');
     /* found=find(newstring, word, 'it');  */ 
	  found=findw(newstring, word, 'it');
      if found=0 then newstring=catx(' ', newstring, word);
   end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2020 11:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Removing-the-exact-duplicate-word-using-FIND-W-function/m-p/615892#M180207</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-01-08T11:27:15Z</dc:date>
    </item>
  </channel>
</rss>

