<?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: multiple left joins in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285110#M58223</link>
    <description>Yes, for #1 you are correct. &lt;BR /&gt;But for any SQL join no of observations in the result set is dependent on the source data, key values and join criteria. Joins creates (at least logically - physical optimization haooends behind the scenes) a product which is filtered by the join criteria.</description>
    <pubDate>Sun, 17 Jul 2016 18:40:11 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2016-07-17T18:40:11Z</dc:date>
    <item>
      <title>multiple left joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285108#M58222</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to understand the mechanism of multiple left joins in SQL.&lt;/P&gt;&lt;P&gt;I wonder how it works? I assume each left join creates an intermediate table and that combines with subequent table. In my example dat1and dat2 yields an intermediate table and it joins with dat3.&lt;/P&gt;&lt;P&gt;Is the total number of observations (records) in multiple left joins equal to the number of observations in first left join?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data dat1;
 input id $ x;
 cards;
 a  1
 b  2
 c  3
 ;
 run;
 
 data dat2;
  input id $ y;
  cards;
  a  1
  ;
 run;
 
 data dat3;
  input id $ z;
  cards;
  b 2
 ;
 run;
 proc sql;
   create table t1 as
    select a.*,b.*,c.*
    from dat1 as a 
        left join dat2 as b
          on a.id = b.id
          left join dat3 as c
          on a.id = c.id;
 quit;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Jul 2016 17:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285108#M58222</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-07-17T17:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: multiple left joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285110#M58223</link>
      <description>Yes, for #1 you are correct. &lt;BR /&gt;But for any SQL join no of observations in the result set is dependent on the source data, key values and join criteria. Joins creates (at least logically - physical optimization haooends behind the scenes) a product which is filtered by the join criteria.</description>
      <pubDate>Sun, 17 Jul 2016 18:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285110#M58223</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-07-17T18:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: multiple left joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285117#M58228</link>
      <description>@ LinusH, since the first left join preserves the number of observations in table a (dat1), this eventually will be preserved in later left joins, right?</description>
      <pubDate>Sun, 17 Jul 2016 19:47:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285117#M58228</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-07-17T19:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: multiple left joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285126#M58231</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;I wonder how it works? I assume each left join creates an intermediate table and that combines with subsequent&amp;nbsp;table. In my example dat1and dat2 yields an intermediate table and it joins with dat3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;True. Unless you alter join operations order with parentheses.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the total number of observations (records) in multiple left joins equal to the number of observations in first left join?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;Not necessarily, if there are multiple matches on the right side, there can be more records in the joined table than there were in the left table.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2016 20:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285126#M58231</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-17T20:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: multiple left joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285129#M58234</link>
      <description>Not necessarily. &lt;BR /&gt;As per my previous answer, ech join could be 1 to many,  or even many to many which would expand the no of result observations.</description>
      <pubDate>Sun, 17 Jul 2016 21:19:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-left-joins/m-p/285129#M58234</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-07-17T21:19:43Z</dc:date>
    </item>
  </channel>
</rss>

