<?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: Proc Sql Joins in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931555#M366465</link>
    <description>&lt;P&gt;Please reread your posted code very carefully. Then rephrase you question in terms of the code shown.&lt;/P&gt;
&lt;P&gt;Your code does not mention "table1" or "table2" anywhere. It shows something that would make you think that those "tables" were created but if you run that code you will see all sorts of errors because where Table1 and Table2 appear they are not valid as code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My best &lt;STRONG&gt;guess&lt;/STRONG&gt; is that you are looking at a miss-matched "code" with "expected results" that do not use the table names with "example" results because of a cut-and-paste error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello there,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data three;&lt;BR /&gt;input x a$;&lt;BR /&gt;datalines;&lt;BR /&gt;1 a1&lt;BR /&gt;1 a2&lt;BR /&gt;2 b1&lt;BR /&gt;2 b2&lt;BR /&gt;4 d&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Data four;&lt;BR /&gt;input x b$;&lt;BR /&gt;datalines;&lt;BR /&gt;2 x1&lt;BR /&gt;2 x2&lt;BR /&gt;3 y&lt;BR /&gt;5 v&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;title 'Table Merged';&lt;BR /&gt;select coalesce(three.x, four.x)&lt;BR /&gt;as x, a, b&lt;BR /&gt;from three&lt;BR /&gt;full join&lt;BR /&gt;four&lt;BR /&gt;on three.x = four.x;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;table1&lt;BR /&gt;x&amp;nbsp; &amp;nbsp; &amp;nbsp;a&amp;nbsp; &amp;nbsp; &amp;nbsp; b&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;a2&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data merged;&lt;BR /&gt;merge three four;&lt;BR /&gt;by x;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;table2;&lt;/P&gt;
&lt;P&gt;x&amp;nbsp; &amp;nbsp; a&amp;nbsp; &amp;nbsp; b&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; a1&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand While the proc sq join starts with table1 instead of&amp;nbsp;table2.&lt;/P&gt;
&lt;P&gt;Please clariification?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jun 2024 13:47:19 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-06-10T13:47:19Z</dc:date>
    <item>
      <title>Proc Sql Joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931519#M366455</link>
      <description>&lt;P&gt;Hello there,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data three;&lt;BR /&gt;input x a$;&lt;BR /&gt;datalines;&lt;BR /&gt;1 a1&lt;BR /&gt;1 a2&lt;BR /&gt;2 b1&lt;BR /&gt;2 b2&lt;BR /&gt;4 d&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Data four;&lt;BR /&gt;input x b$;&lt;BR /&gt;datalines;&lt;BR /&gt;2 x1&lt;BR /&gt;2 x2&lt;BR /&gt;3 y&lt;BR /&gt;5 v&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;title 'Table Merged';&lt;BR /&gt;select coalesce(three.x, four.x)&lt;BR /&gt;as x, a, b&lt;BR /&gt;from three&lt;BR /&gt;full join&lt;BR /&gt;four&lt;BR /&gt;on three.x = four.x;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;table1&lt;BR /&gt;x&amp;nbsp; &amp;nbsp; &amp;nbsp;a&amp;nbsp; &amp;nbsp; &amp;nbsp; b&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;a2&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data merged;&lt;BR /&gt;merge three four;&lt;BR /&gt;by x;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;table2;&lt;/P&gt;
&lt;P&gt;x&amp;nbsp; &amp;nbsp; a&amp;nbsp; &amp;nbsp; b&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; a1&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand While the proc sq join starts with table1 instead of&amp;nbsp;table2.&lt;/P&gt;
&lt;P&gt;Please clariification?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 09:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931519#M366455</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2024-06-10T09:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931538#M366460</link>
      <description>&lt;P&gt;I don't understand the question.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 12:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931538#M366460</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-10T12:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931555#M366465</link>
      <description>&lt;P&gt;Please reread your posted code very carefully. Then rephrase you question in terms of the code shown.&lt;/P&gt;
&lt;P&gt;Your code does not mention "table1" or "table2" anywhere. It shows something that would make you think that those "tables" were created but if you run that code you will see all sorts of errors because where Table1 and Table2 appear they are not valid as code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My best &lt;STRONG&gt;guess&lt;/STRONG&gt; is that you are looking at a miss-matched "code" with "expected results" that do not use the table names with "example" results because of a cut-and-paste error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello there,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data three;&lt;BR /&gt;input x a$;&lt;BR /&gt;datalines;&lt;BR /&gt;1 a1&lt;BR /&gt;1 a2&lt;BR /&gt;2 b1&lt;BR /&gt;2 b2&lt;BR /&gt;4 d&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Data four;&lt;BR /&gt;input x b$;&lt;BR /&gt;datalines;&lt;BR /&gt;2 x1&lt;BR /&gt;2 x2&lt;BR /&gt;3 y&lt;BR /&gt;5 v&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;title 'Table Merged';&lt;BR /&gt;select coalesce(three.x, four.x)&lt;BR /&gt;as x, a, b&lt;BR /&gt;from three&lt;BR /&gt;full join&lt;BR /&gt;four&lt;BR /&gt;on three.x = four.x;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;table1&lt;BR /&gt;x&amp;nbsp; &amp;nbsp; &amp;nbsp;a&amp;nbsp; &amp;nbsp; &amp;nbsp; b&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;a2&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data merged;&lt;BR /&gt;merge three four;&lt;BR /&gt;by x;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;table2;&lt;/P&gt;
&lt;P&gt;x&amp;nbsp; &amp;nbsp; a&amp;nbsp; &amp;nbsp; b&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; a1&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand While the proc sq join starts with table1 instead of&amp;nbsp;table2.&lt;/P&gt;
&lt;P&gt;Please clariification?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 13:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931555#M366465</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-10T13:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931677#M366512</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sorry for the confusion. If you check the result of the match merging, you will notice that the first observation is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;x&amp;nbsp; &amp;nbsp; a&amp;nbsp; &amp;nbsp; b&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; a1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;while for the proc sql full join it is&lt;/P&gt;
&lt;P&gt;x&amp;nbsp; &amp;nbsp; a&amp;nbsp; &amp;nbsp; b&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; a2&lt;/P&gt;
&lt;P&gt;I'm not sure why the sql join jumped the first observation 1&amp;nbsp; a1 in table three and decide to start from 1&amp;nbsp; a2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data three;&lt;BR /&gt;input x a$;&lt;BR /&gt;datalines;&lt;BR /&gt;1 a1&lt;BR /&gt;1 a2&lt;BR /&gt;2 b1&lt;BR /&gt;2 b2&lt;BR /&gt;4 d&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Data four;&lt;BR /&gt;input x b$;&lt;BR /&gt;datalines;&lt;BR /&gt;2 x1&lt;BR /&gt;2 x2&lt;BR /&gt;3 y&lt;BR /&gt;5 v&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;title 'Table Merged';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select coalesce(three.x, four.x)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;as x, a, b&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from three&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;full join&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;four&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;on three.x = four.x;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data merged;&lt;BR /&gt;merge three four;&lt;BR /&gt;by x;&lt;BR /&gt;run;&lt;/SPAN&gt;&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>Tue, 11 Jun 2024 10:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931677#M366512</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2024-06-11T10:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931682#M366516</link>
      <description>&lt;P&gt;In SQL, the order of the output can be changed by using ORDER BY in your SQL statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also please note that although SQL and MERGE in a DATA step do very similar things, they are not identical and in some cases will not produce the same results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 11:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931682#M366516</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-11T11:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931688#M366522</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you, sir. I understand this; I just want to know if there is any rationale for the Proc SQL join behaving this way.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 12:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931688#M366522</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2024-06-11T12:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931689#M366523</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you, sir. I understand this; I just want to know if there is any rationale for the SQL behaving this way.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The default ordering of records in an SQL output is determined by the internal SQL algorithm. I am not aware of any explanation of what that internal SQL algorithm does, and its kind of irrelevant anyway as you can change the ordering of the records to whatever you want.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 12:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931689#M366523</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-11T12:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931701#M366531</link>
      <description>&lt;P&gt;With some SQL queries involving the same data set you can get different output order. SQL is designed for SET operations not row -by-row operations. So if you do not specify something to control the order it can be problematic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And see if you get the order I do by changing the Select to a Select Distinct:&lt;/P&gt;
&lt;PRE&gt;proc sql;
title 'Table Merged';
select distinct coalesce(three.x, four.x)
as x, a, b
from three
full join
four
on three.x = four.x;
quit;&lt;/PRE&gt;
&lt;P&gt;Which gives me an order of:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure SQL: Query Results" cellspacing="0" cellpadding="3"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r m header" scope="col"&gt;x&lt;/TH&gt;
&lt;TH class="l m header" scope="col"&gt;a&lt;/TH&gt;
&lt;TH class="l m header" scope="col"&gt;b&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="l data"&gt;a1&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="l data"&gt;a2&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="l data"&gt;b1&lt;/TD&gt;
&lt;TD class="l data"&gt;x1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="l data"&gt;b1&lt;/TD&gt;
&lt;TD class="l data"&gt;x2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="l data"&gt;b2&lt;/TD&gt;
&lt;TD class="l data"&gt;x1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="l data"&gt;b2&lt;/TD&gt;
&lt;TD class="l data"&gt;x2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;y&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="l data"&gt;d&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;v&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Merge however does process row-by-row.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 13:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931701#M366531</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-11T13:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Joins</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931761#M366556</link>
      <description>&lt;P&gt;Nothing has been "skipped".&amp;nbsp; All observations are accounted for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SQL full join produces these records.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1718127416536.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97219i0A6CFAE17D5A790D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1718127416536.png" alt="Tom_0-1718127416536.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;So you can see both the observations with X=1 are there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data step merge does a completely different operation and produces these results:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_1-1718127500248.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97220iB055B71636B1E19F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_1-1718127500248.png" alt="Tom_1-1718127500248.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Notice the big difference in the way that the multiple observations with X=2 are handled.&amp;nbsp; In SQL a full cartesian product is produced.&amp;nbsp; So 2 observations from TABLE3 and 2 observations from TABLE4 generate 2x2=4 observations output.&amp;nbsp; In general for N observations from one dataset and M observations from the other then the full join will produce NXM observations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the DATA step the observations a matched in the order they appear.&amp;nbsp; So the 2 observations from TABLE3 are matched with the 2 observations from TABLE4 and the result is 2 observations.&amp;nbsp; In general for N observations from one dataset and M observations from the other the merge will result in MAX(N,M) observations.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 17:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Sql-Joins/m-p/931761#M366556</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-06-11T17:44:15Z</dc:date>
    </item>
  </channel>
</rss>

