<?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: Logic behind left joint ?? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Logic-behind-left-join/m-p/308274#M66126</link>
    <description>&lt;P&gt;Which of the output lines surprise you? All follow your condition.&lt;/P&gt;
&lt;P&gt;The first, fourth and fifth records of your datasets are taken as is because there are no matching ManagerID's.&lt;/P&gt;
&lt;P&gt;The second and third each find two matches, and the names from those appear in Manager_name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unless an explicit order is specified, the order of the output is determined by the internal mechanism of SQL.&lt;/P&gt;
&lt;P&gt;Which seems to take the key of the left side in the join for the order.&lt;/P&gt;</description>
    <pubDate>Mon, 31 Oct 2016 14:04:20 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-10-31T14:04:20Z</dc:date>
    <item>
      <title>Logic behind left join ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Logic-behind-left-join/m-p/308271#M66124</link>
      <description>&lt;P&gt;Yes I know I should write as below :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"on a.ManagerID=b.ID;"&lt;/P&gt;
&lt;P&gt;but when i'm writting as below how i'm getting the output can someone please explain logic how output calculated&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data ds1;&lt;BR /&gt;input Name $ ID ManagerID;&lt;BR /&gt;cards;&lt;BR /&gt;Smith 123 456&lt;BR /&gt;Robert 456 .&lt;BR /&gt;William 222 456&lt;BR /&gt;Daniel 777 222&lt;BR /&gt;Cook 383 222&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select a.*, b.Name as Manager_name from ds1 as a left join ds1 as b&lt;BR /&gt;on b.ManagerID=a.ID;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Output :&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;SAS Output&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;Name ID ManagerID Manager_name
&lt;TABLE cellspacing="0" cellpadding="5"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Smith&lt;/TD&gt;
&lt;TD&gt;123&lt;/TD&gt;
&lt;TD&gt;456&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;William&lt;/TD&gt;
&lt;TD&gt;222&lt;/TD&gt;
&lt;TD&gt;456&lt;/TD&gt;
&lt;TD&gt;Cook&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;William&lt;/TD&gt;
&lt;TD&gt;222&lt;/TD&gt;
&lt;TD&gt;456&lt;/TD&gt;
&lt;TD&gt;Daniel&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Cook&lt;/TD&gt;
&lt;TD&gt;383&lt;/TD&gt;
&lt;TD&gt;222&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Robert&lt;/TD&gt;
&lt;TD&gt;456&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;Smith&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Robert&lt;/TD&gt;
&lt;TD&gt;456&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;William&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Daniel&lt;/TD&gt;
&lt;TD&gt;777&lt;/TD&gt;
&lt;TD&gt;222&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 14:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Logic-behind-left-join/m-p/308271#M66124</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2016-10-31T14:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Logic behind left joint ??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Logic-behind-left-join/m-p/308274#M66126</link>
      <description>&lt;P&gt;Which of the output lines surprise you? All follow your condition.&lt;/P&gt;
&lt;P&gt;The first, fourth and fifth records of your datasets are taken as is because there are no matching ManagerID's.&lt;/P&gt;
&lt;P&gt;The second and third each find two matches, and the names from those appear in Manager_name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unless an explicit order is specified, the order of the output is determined by the internal mechanism of SQL.&lt;/P&gt;
&lt;P&gt;Which seems to take the key of the left side in the join for the order.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2016 14:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Logic-behind-left-join/m-p/308274#M66126</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-31T14:04:20Z</dc:date>
    </item>
  </channel>
</rss>

