<?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 Number of records are different in left join &amp; merge in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Number-of-records-are-different-in-left-join-merge/m-p/200563#M50066</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I have a following query, which returns &lt;STRONG&gt;636302&lt;/STRONG&gt; number of records:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5em; font-size: 10pt;"&gt;&lt;STRONG&gt;proc sql; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table application as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select distinct&amp;nbsp; a.*,&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;b.App1, &lt;/SPAN&gt;b.App2, c.EMP1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from app1 a left join app2 b on (&lt;SPAN style="font-size: 13.3333330154419px;"&gt;a.Application_Number&lt;/SPAN&gt;=b.AA_No) left join app3 c on (a.Application_Number=c.APP_ID);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried rewriting the above query using merge as follows, but this query is returning &lt;STRONG&gt;635610&lt;/STRONG&gt; number of records:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data application;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;merge app1 (IN=a keep=_all_) app2 (in=b keep= App1 App2 AA_No&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; rename=(AA_No=Application_Number))&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;app3 (in=c keep=EMP1&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; APP_ID rename=(APP_ID=Application_Number));&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;by Application_Number;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if a;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RUN;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Can someone please tell me if I'm missing something above in the merge query because of which a difference of 692 records is coming ?&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Mar 2015 05:24:09 GMT</pubDate>
    <dc:creator>KP12</dc:creator>
    <dc:date>2015-03-13T05:24:09Z</dc:date>
    <item>
      <title>Number of records are different in left join &amp; merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Number-of-records-are-different-in-left-join-merge/m-p/200563#M50066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I have a following query, which returns &lt;STRONG&gt;636302&lt;/STRONG&gt; number of records:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5em; font-size: 10pt;"&gt;&lt;STRONG&gt;proc sql; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table application as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select distinct&amp;nbsp; a.*,&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;b.App1, &lt;/SPAN&gt;b.App2, c.EMP1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from app1 a left join app2 b on (&lt;SPAN style="font-size: 13.3333330154419px;"&gt;a.Application_Number&lt;/SPAN&gt;=b.AA_No) left join app3 c on (a.Application_Number=c.APP_ID);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried rewriting the above query using merge as follows, but this query is returning &lt;STRONG&gt;635610&lt;/STRONG&gt; number of records:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data application;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;merge app1 (IN=a keep=_all_) app2 (in=b keep= App1 App2 AA_No&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; rename=(AA_No=Application_Number))&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;app3 (in=c keep=EMP1&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; APP_ID rename=(APP_ID=Application_Number));&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;by Application_Number;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if a;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RUN;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Can someone please tell me if I'm missing something above in the merge query because of which a difference of 692 records is coming ?&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2015 05:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Number-of-records-are-different-in-left-join-merge/m-p/200563#M50066</guid>
      <dc:creator>KP12</dc:creator>
      <dc:date>2015-03-13T05:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Number of records are different in left join &amp; merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Number-of-records-are-different-in-left-join-merge/m-p/200564#M50067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A SAS merge doesn't work exactly the same like a SQL join and you will get different results for many:many relationships.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please refer to this post and the links provided there &lt;A __default_attr="114758" __jive_macro_name="message" class="jive_macro jive_macro_message" href="https://communities.sas.com/"&gt;&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2015 06:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Number-of-records-are-different-in-left-join-merge/m-p/200564#M50067</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-03-13T06:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Number of records are different in left join &amp; merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Number-of-records-are-different-in-left-join-merge/m-p/200565#M50068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have 3 records for a key in dataset1, and 2 records for a key in dataset2, a merge in a data step by that key will give you 3 records, the join in SQL will give you 6 (cartesian product).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2015 06:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Number-of-records-are-different-in-left-join-merge/m-p/200565#M50068</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-03-13T06:31:05Z</dc:date>
    </item>
  </channel>
</rss>

