<?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: Merging table with a like? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32565#M7850</link>
    <description>Hello Spud,&lt;BR /&gt;
&lt;BR /&gt;
It is slow because a cartesian product is needed to find the matches. I don't think there are very performant alternatives. &lt;BR /&gt;
&lt;BR /&gt;
Yoba</description>
    <pubDate>Thu, 02 Jul 2009 18:21:09 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-07-02T18:21:09Z</dc:date>
    <item>
      <title>Merging table with a like?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32560#M7845</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
Im trying to merge two tables but the variables aren't exactly the same.&lt;BR /&gt;
in sql it is possible, using a like join.&lt;BR /&gt;
select *&lt;BR /&gt;
table1 a left join table2 b&lt;BR /&gt;
on a.var LIKE b.var&lt;BR /&gt;
&lt;BR /&gt;
what i have is a list of words in one table2 ie&lt;BR /&gt;
var&lt;BR /&gt;
it&lt;BR /&gt;
is&lt;BR /&gt;
&lt;BR /&gt;
and in table1 i have words like&lt;BR /&gt;
fit&lt;BR /&gt;
food&lt;BR /&gt;
his&lt;BR /&gt;
you&lt;BR /&gt;
hit&lt;BR /&gt;
item&lt;BR /&gt;
....etc&lt;BR /&gt;
&lt;BR /&gt;
so i want to flag all the words in table that contain any word from table 2.&lt;BR /&gt;
to get&lt;BR /&gt;
fit     1&lt;BR /&gt;
food  0&lt;BR /&gt;
his    1&lt;BR /&gt;
you   0&lt;BR /&gt;
hit    1&lt;BR /&gt;
item  1&lt;BR /&gt;
&lt;BR /&gt;
Is this possible?&lt;BR /&gt;
&lt;BR /&gt;
I hope i have made myself clear enough.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Simon</description>
      <pubDate>Fri, 15 May 2009 11:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32560#M7845</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-15T11:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Merging table with a like?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32561#M7846</link>
      <description>I don't believe SAS has equivalent support/behavior with LIKE processing, as you describe.  You may want to open a SAS support track to get a specific and accurate response from SAS.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 15 May 2009 19:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32561#M7846</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-15T19:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Merging table with a like?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32562#M7847</link>
      <description>put the short list of words into memory either hash table or array. Then pass through the larger table; test each entry in memory against the row from the large table with whatever "like" test you need. &lt;BR /&gt;
depending on your data model, you may want to select for every word in the memory which is "like" or just for the first.&lt;BR /&gt;
 &lt;BR /&gt;
good luck&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Sat, 16 May 2009 14:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32562#M7847</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-05-16T14:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Merging table with a like?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32563#M7848</link>
      <description>Hello Spud,&lt;BR /&gt;
&lt;BR /&gt;
Could you try this?&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table T02_contains as&lt;BR /&gt;
select a.var, count(distinct b.var) as count_distinct, (calculated count_Distinct gt 0) as flag_exist&lt;BR /&gt;
from T01_table1 a LEFT JOIN T01_table2 b&lt;BR /&gt;
on index(a.var,trim(b.var)) gt 0&lt;BR /&gt;
group by 1;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
I tested it with the following data sets:&lt;BR /&gt;
&lt;BR /&gt;
* Test data;&lt;BR /&gt;
data T01_table2;&lt;BR /&gt;
infile cards;&lt;BR /&gt;
length var $30;&lt;BR /&gt;
input var;&lt;BR /&gt;
cards;&lt;BR /&gt;
var&lt;BR /&gt;
it&lt;BR /&gt;
is&lt;BR /&gt;
fi&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data T01_table1;&lt;BR /&gt;
infile cards;&lt;BR /&gt;
length var $30;&lt;BR /&gt;
input var;&lt;BR /&gt;
cards;&lt;BR /&gt;
fit&lt;BR /&gt;
food&lt;BR /&gt;
his&lt;BR /&gt;
you&lt;BR /&gt;
hit&lt;BR /&gt;
item&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Watch out: it will perform a cartesian product. As a consequence, it is time and resource consuming. But I think it will do what you want. &lt;BR /&gt;
&lt;BR /&gt;
Could you let me know whether this helped,&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
&lt;BR /&gt;
Yoba</description>
      <pubDate>Sat, 16 May 2009 20:10:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32563#M7848</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-16T20:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Merging table with a like?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32564#M7849</link>
      <description>Sorry for the extremely late reply....&lt;BR /&gt;
Yes it worked but was incredibly slow....and i was really after a SAS equivalent not a proc sql.&lt;BR /&gt;
But thanks anyway

Message was edited by: Spud</description>
      <pubDate>Thu, 02 Jul 2009 12:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32564#M7849</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-07-02T12:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Merging table with a like?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32565#M7850</link>
      <description>Hello Spud,&lt;BR /&gt;
&lt;BR /&gt;
It is slow because a cartesian product is needed to find the matches. I don't think there are very performant alternatives. &lt;BR /&gt;
&lt;BR /&gt;
Yoba</description>
      <pubDate>Thu, 02 Jul 2009 18:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32565#M7850</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-07-02T18:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Merging table with a like?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32566#M7851</link>
      <description>Suggest you investigate DATA step functions (FIND, INDEX, INDEXW) and possibly a HASH table approach which may be suitable for your needs.  &lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 02 Jul 2009 18:53:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merging-table-with-a-like/m-p/32566#M7851</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-07-02T18:53:34Z</dc:date>
    </item>
  </channel>
</rss>

