<?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: Partial match merging in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854042#M337552</link>
    <description>&lt;P&gt;Your description of the logic needs some additional specification to be clear.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does one of below two SQLs return what you're after?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select 
    a.*,
    b.var4
  from 
    a
    inner join
    b
      on find(a.var2,b.var4,'it')&amp;gt;0
  ;
quit;


proc sql;
  select 
    a.*,
    b.var4
  from 
    a
    inner join
    (select distinct upcase(b.var4) as var4 from b) as b
      on find(a.var2,b.var4,'it')&amp;gt;0
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1673931584424.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79428i3BE02BED00D9F5A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1673931584424.png" alt="Patrick_0-1673931584424.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Please note that even with the 2nd SQL if there is more than one matching substring in table A (like: Bluegreen water) then you would still get into a many:many situation. Is that what you want? If not what should happen in such a case? (please amend your sample data with such a case and show us the desired result).&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jan 2023 06:47:26 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2023-01-17T06:47:26Z</dc:date>
    <item>
      <title>Partial match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854032#M337549</link>
      <description>&lt;P&gt;I have two tables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data A;&lt;BR /&gt;length var2 $ 50;&lt;BR /&gt;input&lt;BR /&gt;var1 var2 $ &amp;amp;;&lt;BR /&gt;datalines;&lt;BR /&gt;1 zzzblue sky&lt;BR /&gt;2 BlUe sky &lt;BR /&gt;3 green leaf&lt;BR /&gt;4 red apple&lt;BR /&gt;5 red apple &lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data B;&lt;BR /&gt;length var4 $ 50;&lt;BR /&gt;input&lt;BR /&gt;var3 var4 $ &amp;amp;;&lt;BR /&gt;datalines;&lt;BR /&gt;14545 BLUE &lt;BR /&gt;26464 blue &lt;BR /&gt;34646 gReen &lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Var4 in dataset B matches partially with var2 in dataset A. I need help with a many to many merge based on this partial match where the new dataset will look like this-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="256"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;var1&lt;/TD&gt;
&lt;TD width="64"&gt;var2&lt;/TD&gt;
&lt;TD width="64"&gt;var3&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;var4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;zzzblue sky&lt;/TD&gt;
&lt;TD&gt;14545&lt;/TD&gt;
&lt;TD&gt;BLUE&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;BlUe sky&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;26464&lt;/TD&gt;
&lt;TD&gt;blue&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;green leaf&lt;/TD&gt;
&lt;TD&gt;34646&lt;/TD&gt;
&lt;TD&gt;gReen&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 17 Jan 2023 00:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854032#M337549</guid>
      <dc:creator>dac_js</dc:creator>
      <dc:date>2023-01-17T00:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: Partial match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854039#M337551</link>
      <description>&lt;P&gt;You don't show a "many to many" merge, or join.&lt;/P&gt;
&lt;P&gt;You seem to have some additional restriction, not stated, as to why you do not have a result like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="256"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;zzzblue sky&lt;/TD&gt;
&lt;TD&gt;26464&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;blue&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;So you need to provide the other rules involved.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 02:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854039#M337551</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-17T02:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Partial match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854042#M337552</link>
      <description>&lt;P&gt;Your description of the logic needs some additional specification to be clear.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does one of below two SQLs return what you're after?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select 
    a.*,
    b.var4
  from 
    a
    inner join
    b
      on find(a.var2,b.var4,'it')&amp;gt;0
  ;
quit;


proc sql;
  select 
    a.*,
    b.var4
  from 
    a
    inner join
    (select distinct upcase(b.var4) as var4 from b) as b
      on find(a.var2,b.var4,'it')&amp;gt;0
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1673931584424.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79428i3BE02BED00D9F5A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1673931584424.png" alt="Patrick_0-1673931584424.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Please note that even with the 2nd SQL if there is more than one matching substring in table A (like: Bluegreen water) then you would still get into a many:many situation. Is that what you want? If not what should happen in such a case? (please amend your sample data with such a case and show us the desired result).&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 06:47:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854042#M337552</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-01-17T06:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Partial match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854046#M337553</link>
      <description>&lt;P&gt;You have to explain in detail the rules to be applied.&lt;/P&gt;
&lt;P&gt;The first two obs of both datasets match, so why is only one match expected to be written to the result dataset?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 06:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854046#M337553</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2023-01-17T06:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Partial match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854479#M337693</link>
      <description>Thanks! I missed the additional specification.</description>
      <pubDate>Thu, 19 Jan 2023 02:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854479#M337693</guid>
      <dc:creator>dac_js</dc:creator>
      <dc:date>2023-01-19T02:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Partial match merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854480#M337694</link>
      <description>Thanks! I missed the additional restriction.</description>
      <pubDate>Thu, 19 Jan 2023 02:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Partial-match-merging/m-p/854480#M337694</guid>
      <dc:creator>dac_js</dc:creator>
      <dc:date>2023-01-19T02:21:33Z</dc:date>
    </item>
  </channel>
</rss>

