<?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 full words across two columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627526#M185275</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I did come up with a way to do this using multiple scan functions but it's really clunky and inefficient. I'm hoping for a more efficient and automated approach.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you need a DO loop in a DATA step, along with the COUNTW and SCAN and FIND functions. So, it's not clear what you did or whether it can be improved. Can you show us what you have tried?&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2020 15:01:05 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-02-26T15:01:05Z</dc:date>
    <item>
      <title>Matching full words across two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627520#M185273</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data file which has two string variables that contain multiple words each:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;V1&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; &amp;nbsp; &amp;nbsp;V2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;abc def ghi jkl&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;abc&lt;/P&gt;&lt;P&gt;def ghi jkl&amp;nbsp; &amp;nbsp;abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;abc&lt;/P&gt;&lt;P&gt;abcdef&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc&lt;/P&gt;&lt;P&gt;abc&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; &amp;nbsp;abc def&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each string can contain one or more words. What I'm trying to do is identify records where any of the full words in V2 is found (also as a full word) in V1. So the first, second and last records would be matches, but the third record would not because the value in V2 does not match to a full word value found in V1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did come up with a way to do this using multiple scan functions but it's really clunky and inefficient. I'm hoping for a more efficient and automated approach.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is much appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 14:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627520#M185273</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2020-02-26T14:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Matching full words across two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627526#M185275</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I did come up with a way to do this using multiple scan functions but it's really clunky and inefficient. I'm hoping for a more efficient and automated approach.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you need a DO loop in a DATA step, along with the COUNTW and SCAN and FIND functions. So, it's not clear what you did or whether it can be improved. Can you show us what you have tried?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 15:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627526#M185275</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-26T15:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Matching full words across two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627532#M185279</link>
      <description>&lt;P&gt;Basically a lot of scan functions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if scan(v1, 1, ' ') = scan(v2, 1, ' ') or&lt;/P&gt;&lt;P&gt;&amp;nbsp; scan(v1, 2, ' ') = scan(v2, 1, ' ') etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is not a great approach because the strings can have up to 9 words (and it's super clunky).&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 15:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627532#M185279</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2020-02-26T15:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Matching full words across two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627535#M185281</link>
      <description>&lt;P&gt;Here is how I would do it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input V1 $ 1-16 V2 $ 17-25;
datalines;
abc def ghi jkl abc    
def ghi jkl abc abc    
abcdef          abc    
abc             abc def
;

data want (drop=i);
    set have;
    do i = 1 to countw(V2);
        if findw(V1, scan(V2, i)) then do;
            output;
            leave;
        end;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;V1               V2 
abc def ghi jkl  abc 
def ghi jkl abc  abc 
abc              abc def &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 15:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627535#M185281</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-26T15:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Matching full words across two columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627536#M185282</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;, this is exactly what I had in mind.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 15:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-full-words-across-two-columns/m-p/627536#M185282</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-26T15:20:03Z</dc:date>
    </item>
  </channel>
</rss>

