<?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: When use PROC MERGE in SAS EG to merge 2 tables from Netezza, no need to sort the data. Why? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414428#M26669</link>
    <description>&lt;P&gt;The rules you're referencing are for a data step merge.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's no PROC MERGE that I'm aware of, but if you use a SQL merge, either in SAS BASE, EG Query Builder (which is a SQL query builder) or a SQL server it sorts it automatically for the merge, you don't need to first sort. This is a feature of SQL in general. However, there's no guarantee on the sort order unless you also specify the ORDER by statement.&amp;nbsp;&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/178213"&gt;@Pre-app&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS EG 4.3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"For a merge with a BY statement, your data &lt;U&gt;needs to be sorted&lt;/U&gt;, either by using PROC SORT or having data that is in sorted order already, or &lt;U&gt;indexed&lt;/U&gt;&lt;U&gt; using the BY variables&lt;/U&gt;."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;But,&lt;/STRONG&gt; when I use &lt;STRONG&gt;PROC MERGE&lt;/STRONG&gt; to merge 2 tables &lt;FONT color="#ff0000"&gt;&lt;FONT color="#000000"&gt;from&lt;/FONT&gt; Netezza&lt;/FONT&gt;, I can &lt;FONT color="#ff0000"&gt;skip over&amp;nbsp;the step of &lt;STRONG&gt;PROC SORT&lt;/STRONG&gt;&lt;/FONT&gt;. The output is correct and&amp;nbsp;sorted.&amp;nbsp;Why? Are the tables from Netezza pre-defined by something?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, (Netez is a libref for a Netezza database. 1st, create 2 tables in Netezza; 2nd, use PROC MERGE)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt; Netez.A1;&lt;/P&gt;
&lt;P&gt;Input ID Mth Name$ Height;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;7 5 D 2&lt;/P&gt;
&lt;P&gt;1 1 A 1&lt;/P&gt;
&lt;P&gt;3 2 B 2&lt;/P&gt;
&lt;P&gt;9 5 E 2&lt;/P&gt;
&lt;P&gt;5 3 C 2&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt; Netez.A2;&lt;/P&gt;
&lt;P&gt;Input ID Mth Name$ Weight;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;5 3 C 4&lt;/P&gt;
&lt;P&gt;2 1 A 2&lt;/P&gt;
&lt;P&gt;7 5 D 5&lt;/P&gt;
&lt;P&gt;4 2 B 3&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; dummy;&lt;/P&gt;
&lt;P&gt;merge Netez.A1 (in=x) Netez.A2 (in=y);&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;if x;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Nov 2017 15:42:24 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-11-17T15:42:24Z</dc:date>
    <item>
      <title>When use PROC MERGE in SAS EG to merge 2 tables from Netezza, no need to sort the data. Why?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414419#M26668</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS EG 4.3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"For a merge with a BY statement, your data &lt;U&gt;needs to be sorted&lt;/U&gt;, either by using PROC SORT or having data that is in sorted order already, or &lt;U&gt;indexed&lt;/U&gt;&lt;U&gt; using the BY variables&lt;/U&gt;."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;But,&lt;/STRONG&gt; when I use &lt;STRONG&gt;PROC MERGE&lt;/STRONG&gt; to merge 2 tables &lt;FONT color="#ff0000"&gt;&lt;FONT color="#000000"&gt;from&lt;/FONT&gt; Netezza&lt;/FONT&gt;, I can &lt;FONT color="#ff0000"&gt;skip over&amp;nbsp;the step of &lt;STRONG&gt;PROC SORT&lt;/STRONG&gt;&lt;/FONT&gt;. The output is correct and&amp;nbsp;sorted.&amp;nbsp;Why? Are the tables from Netezza pre-defined by something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, (Netez is a libref for a Netezza database. 1st, create 2 tables in Netezza; 2nd, use PROC MERGE)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt; Netez.A1;&lt;/P&gt;&lt;P&gt;Input ID Mth Name$ Height;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;7 5 D 2&lt;/P&gt;&lt;P&gt;1 1 A 1&lt;/P&gt;&lt;P&gt;3 2 B 2&lt;/P&gt;&lt;P&gt;9 5 E 2&lt;/P&gt;&lt;P&gt;5 3 C 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt; Netez.A2;&lt;/P&gt;&lt;P&gt;Input ID Mth Name$ Weight;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;5 3 C 4&lt;/P&gt;&lt;P&gt;2 1 A 2&lt;/P&gt;&lt;P&gt;7 5 D 5&lt;/P&gt;&lt;P&gt;4 2 B 3&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; dummy;&lt;/P&gt;&lt;P&gt;merge Netez.A1 (in=x) Netez.A2 (in=y);&lt;/P&gt;&lt;P&gt;by id;&lt;/P&gt;&lt;P&gt;if x;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 15:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414419#M26668</guid>
      <dc:creator>Pre-app</dc:creator>
      <dc:date>2017-11-17T15:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: When use PROC MERGE in SAS EG to merge 2 tables from Netezza, no need to sort the data. Why?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414428#M26669</link>
      <description>&lt;P&gt;The rules you're referencing are for a data step merge.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's no PROC MERGE that I'm aware of, but if you use a SQL merge, either in SAS BASE, EG Query Builder (which is a SQL query builder) or a SQL server it sorts it automatically for the merge, you don't need to first sort. This is a feature of SQL in general. However, there's no guarantee on the sort order unless you also specify the ORDER by statement.&amp;nbsp;&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/178213"&gt;@Pre-app&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS EG 4.3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"For a merge with a BY statement, your data &lt;U&gt;needs to be sorted&lt;/U&gt;, either by using PROC SORT or having data that is in sorted order already, or &lt;U&gt;indexed&lt;/U&gt;&lt;U&gt; using the BY variables&lt;/U&gt;."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;But,&lt;/STRONG&gt; when I use &lt;STRONG&gt;PROC MERGE&lt;/STRONG&gt; to merge 2 tables &lt;FONT color="#ff0000"&gt;&lt;FONT color="#000000"&gt;from&lt;/FONT&gt; Netezza&lt;/FONT&gt;, I can &lt;FONT color="#ff0000"&gt;skip over&amp;nbsp;the step of &lt;STRONG&gt;PROC SORT&lt;/STRONG&gt;&lt;/FONT&gt;. The output is correct and&amp;nbsp;sorted.&amp;nbsp;Why? Are the tables from Netezza pre-defined by something?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, (Netez is a libref for a Netezza database. 1st, create 2 tables in Netezza; 2nd, use PROC MERGE)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt; Netez.A1;&lt;/P&gt;
&lt;P&gt;Input ID Mth Name$ Height;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;7 5 D 2&lt;/P&gt;
&lt;P&gt;1 1 A 1&lt;/P&gt;
&lt;P&gt;3 2 B 2&lt;/P&gt;
&lt;P&gt;9 5 E 2&lt;/P&gt;
&lt;P&gt;5 3 C 2&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt; Netez.A2;&lt;/P&gt;
&lt;P&gt;Input ID Mth Name$ Weight;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;5 3 C 4&lt;/P&gt;
&lt;P&gt;2 1 A 2&lt;/P&gt;
&lt;P&gt;7 5 D 5&lt;/P&gt;
&lt;P&gt;4 2 B 3&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; dummy;&lt;/P&gt;
&lt;P&gt;merge Netez.A1 (in=x) Netez.A2 (in=y);&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;if x;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 15:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414428#M26669</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-17T15:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: When use PROC MERGE in SAS EG to merge 2 tables from Netezza, no need to sort the data. Why?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414440#M26670</link>
      <description>&lt;P&gt;SQL and SAS were in development around the same time, in the 1970s. One of the foundational concepts of SQL is that the sequence of the records in a table is generally irrelevant; that's why the original language didn't have any concepts to process one row after the other.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As part of this, when you do a join, issues about table sequence are left "behind the scenes", for the SQL compiler to figure out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One fallacy that circulates is that a SQL join is more "efficient" than a SAS merge because the data doesn't need to be sorted; I assure you, there is a sort being done behind the scenes. Computationally, doing a SAS merge on unsorted data is similar to doing a SQL join on the same data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One last comment; don't assume that the output of a SQL join is in any particular order, unless you've used an ORDER BY clause. Theoretically, it could change from one run to the next.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 16:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414440#M26670</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-11-17T16:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: When use PROC MERGE in SAS EG to merge 2 tables from Netezza, no need to sort the data. Why?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414543#M26674</link>
      <description>Thank all.</description>
      <pubDate>Fri, 17 Nov 2017 21:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414543#M26674</guid>
      <dc:creator>Pre-app</dc:creator>
      <dc:date>2017-11-17T21:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: When use PROC MERGE in SAS EG to merge 2 tables from Netezza, no need to sort the data. Why?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414544#M26675</link>
      <description>&lt;P&gt;It is a feature of SAS/Access to .....&lt;/P&gt;
&lt;P&gt;Basically SAS tells the database to give it the records in the right order.&amp;nbsp; So if you are using a BY statement in your DATA or PROC step then SAS will automatically add an ORDER BY clause to the query that it pushes into the database to get the records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 21:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/When-use-PROC-MERGE-in-SAS-EG-to-merge-2-tables-from-Netezza-no/m-p/414544#M26675</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-17T21:44:33Z</dc:date>
    </item>
  </channel>
</rss>

