<?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: Like operator not working during pattern matching in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411746#M100674</link>
    <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
create table final as
select c.*
from child c, Master m where (upper(c.product) like '%' || upper(strip(m.Med_product)) || '%'
                       or upper(m.Med_product) like '%' || upper(strip(c.product))     || '%');
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You have to remove the trailing spaces. I'd use the &lt;FONT face="courier new,courier"&gt;contains&lt;/FONT&gt; operator though as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114436"&gt;@Yavuz&lt;/a&gt;&amp;nbsp;showed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Nov 2017 22:58:34 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2017-11-08T22:58:34Z</dc:date>
    <item>
      <title>Like operator not working during pattern matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411623#M100622</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to find data of child table when its product is matching with Med_product variable from Master dataset and vice versa.&lt;/P&gt;
&lt;P&gt;I tried using below code but I am getting error.&lt;/P&gt;
&lt;P&gt;Can you please help me&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data Master;
input Med_product $15.;
cards;
Metformin-oral
TolazolineK
OXALIPLATINSYRUP
METHOTREXATETAB
CISPLATIN
AZATHIOPRINE
;
run;


data child;
input pid product $15.;
cards;
101 Metformin
102 Tolazolines
107 OXALIPLATINS
103 METHOTREXATETAB
104 AZATHMYCIN
105 METHOTREXATE
106 CISPLATIN LIVI
;
run;

proc sql;
create table final as
select c.*
from child c, Master m where (upper(c.product) like '%' || upper(m.Med_product) || '%'
                            or upper(p.product) like '%' || upper(c.Med_product) || '%');
quit;

proc sql;
create table final as
select c.*
from child c where upper(c.product) like '%' || (select distinct upper(m.Med_product) from Master m) || '%';
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 18:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411623#M100622</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2017-11-08T18:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator not working during pattern matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411653#M100633</link>
      <description>proc sql;&lt;BR /&gt;select catx(" | ",a.product,b.Med_product) as variab&lt;BR /&gt;from master a left join child b&lt;BR /&gt;on strip(upcase(med_product)) contains strip(upcase(product));&lt;BR /&gt;quit;</description>
      <pubDate>Wed, 08 Nov 2017 19:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411653#M100633</guid>
      <dc:creator>Yavuz</dc:creator>
      <dc:date>2017-11-08T19:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator not working during pattern matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411746#M100674</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql;
create table final as
select c.*
from child c, Master m where (upper(c.product) like '%' || upper(strip(m.Med_product)) || '%'
                       or upper(m.Med_product) like '%' || upper(strip(c.product))     || '%');
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You have to remove the trailing spaces. I'd use the &lt;FONT face="courier new,courier"&gt;contains&lt;/FONT&gt; operator though as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/114436"&gt;@Yavuz&lt;/a&gt;&amp;nbsp;showed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 22:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411746#M100674</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-11-08T22:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator not working during pattern matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411760#M100675</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your trying for a fuzzy match on the name then SPEDIS function is very helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table final as&lt;BR /&gt;select *&lt;BR /&gt;from child c, Master&lt;BR /&gt;where find(product,Med_product,'i')&amp;gt;0 or find(Med_product,product,'i')&amp;gt;0;&lt;BR /&gt;quit;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table final as&lt;BR /&gt;select *&lt;BR /&gt;from child c, Master&lt;BR /&gt;where SPEDIS(product,Med_product)&amp;lt;10 or SPEDIS(Med_product,product)&amp;lt;10;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here 10 is the score for the fuzzy match I'm looking for. Go to SPEDIS function documentation to know more about it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 23:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411760#M100675</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2017-11-08T23:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Like operator not working during pattern matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411774#M100677</link>
      <description>&lt;P&gt;Don't include the trailing spaces in your search pattern.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where upper(c.product) like '%' || upper(trim(m.Med_product)) || '%'
   or upper(p.product) like '%' || upper(trim(c.Med_product)) || '%'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or better still just use the FIND() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where find(c.product,m.Med_product,'it')
   or find(p.product,c.Med_product,'it')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also note that the UPPER() function is only available in SQL code. The normal SAS function of UPCASE() can be used anywhere in SAS code.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2017 23:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Like-operator-not-working-during-pattern-matching/m-p/411774#M100677</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-08T23:55:07Z</dc:date>
    </item>
  </channel>
</rss>

