<?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: SQL Left Join - Different default order of observations in outputs between SAS 9.4 and SAS 9.3 in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560635#M10479</link>
    <description>&lt;P&gt;If row order is crucial to your process, add &lt;STRONG&gt;order by&lt;/STRONG&gt; clauses to your SQL queries.&lt;/P&gt;</description>
    <pubDate>Tue, 21 May 2019 20:01:40 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2019-05-21T20:01:40Z</dc:date>
    <item>
      <title>SQL Left Join - Different default order of observations in outputs between SAS 9.4 and SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560634#M10478</link>
      <description>&lt;P&gt;Hi Friends,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on migration of process from SAS 9.3 on Unix Aix to SAS 9.4 on linux.&lt;/P&gt;&lt;P&gt;for one of my process, I find different default ordering of observations in output datasets (created from SQL left join from source tables) in SAS 9.3 M2 (On unix AIX)and SAS 9.4 M4 (on Linux redhat) .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This different ordering of observations are causing different results&amp;nbsp; in downstream as we are removing duplicates based of few variables which don't uniquely represent each row in final table. I tried to use _method_tree option to find the default order of SQL join but it didn't provide much information for the differences.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql _method _tree;&amp;nbsp;&lt;BR /&gt;...&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to find the default ordering of observations on Unix Aix? I will replicate the same ordering explicitly then.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help will be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks ,&lt;/P&gt;&lt;P&gt;Kulbhushan&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 19:57:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560634#M10478</guid>
      <dc:creator>kulbshar</dc:creator>
      <dc:date>2019-05-21T19:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Left Join - Different default order of observations in outputs between SAS 9.4 and SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560635#M10479</link>
      <description>&lt;P&gt;If row order is crucial to your process, add &lt;STRONG&gt;order by&lt;/STRONG&gt; clauses to your SQL queries.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 20:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560635#M10479</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-05-21T20:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Left Join - Different default order of observations in outputs between SAS 9.4 and SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560658#M10481</link>
      <description>&lt;P&gt;If your data on Unix Aix is SAS data then Proc Contents will report on the SORTEDBY information, or the Dictionary.Columns table has a field SORTEDBY that indicates the order in the key sequence a variable may appear so you could recover that information to add Order By to syntax.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 20:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560658#M10481</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-21T20:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Left Join - Different default order of observations in outputs between SAS 9.4 and SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560665#M10482</link>
      <description>&lt;P&gt;Sounds like you were lucky to get consistent results in the old system.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are removing duplicates based on only a partial key and you want to consistently get the same record kept then you probably need to order by ALL of the variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=sorted ;
  by key1 key2 _all_;
run;

data nodups;
  set sorted;
  by key1 key2;
  if first.key2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 May 2019 20:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560665#M10482</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-21T20:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Left Join - Different default order of observations in outputs between SAS 9.4 and SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560668#M10483</link>
      <description>&lt;P&gt;We struck this issue as well when migrating to SAS 9.4. Our solution was to add explicit ORDER BY statements to our SQL queries. This ensured we got the same data outputs in 9.4 versus 9.3.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 21:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560668#M10483</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-05-21T21:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Left Join - Different default order of observations in outputs between SAS 9.4 and SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560671#M10484</link>
      <description>&lt;P&gt;yeah in that case we have to change current production too to have match for passing migration. I am trying to find if somehow I can find default order in current production so that I can put that in order clause of newly migrated code to SAS 9.4 server. Thanks for the feedback.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 22:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560671#M10484</guid>
      <dc:creator>kulbshar</dc:creator>
      <dc:date>2019-05-21T22:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Left Join - Different default order of observations in outputs between SAS 9.4 and SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560673#M10485</link>
      <description>&lt;P&gt;sorted by in proc content provide me the sorted keys on which we explicitly sorted. but the problem is we still have duplicates in those keys.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for examples: we sorted in id1 id2 in production.&amp;nbsp; so you can see ID1 ID2 is not unique and the other variables are sorted by default in SQL join.&lt;/P&gt;&lt;P&gt;But the issue is in SAS 9.3 PROC SQL join is sorting differently than SAS 9.4 on other variables(not ID1 ID2). in later step we are picking last record for ID1 &amp;amp; ID2. but last record is different in SAS 9.3 &amp;amp; SAS 9.4 SQL join.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sources of Join are exact match(even order)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID1 ID2&amp;nbsp; &amp;nbsp;start_dt&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var2&amp;nbsp; &amp;nbsp; &amp;nbsp;var3&amp;nbsp; &amp;nbsp; var4&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1feb2019&amp;nbsp; &amp;nbsp; &amp;nbsp; 22.3&amp;nbsp; &amp;nbsp; &amp;nbsp;33.2&amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1feb2019&amp;nbsp; &amp;nbsp; &amp;nbsp; 22.3&amp;nbsp; &amp;nbsp; &amp;nbsp;33.2&amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3feb2019&amp;nbsp; &amp;nbsp; &amp;nbsp; 22.3&amp;nbsp; &amp;nbsp; &amp;nbsp;33.2&amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2feb2019&amp;nbsp; &amp;nbsp; &amp;nbsp; 24.3&amp;nbsp; &amp;nbsp; &amp;nbsp;34.2&amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sorry If I didn't able to explain it to you better,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 22:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560673#M10485</guid>
      <dc:creator>kulbshar</dc:creator>
      <dc:date>2019-05-21T22:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Left Join - Different default order of observations in outputs between SAS 9.4 and SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560674#M10486</link>
      <description>&lt;P&gt;yeah that's the last solution, we don't want to change current production. if I can fix it&amp;nbsp; in new server i.e. SAS 9.4 using&amp;nbsp; default order in current system on duplicates variables. otherwise the last option to add order clause in both current production and newly migrated system.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 22:24:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560674#M10486</guid>
      <dc:creator>kulbshar</dc:creator>
      <dc:date>2019-05-21T22:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Left Join - Different default order of observations in outputs between SAS 9.4 and SAS 9.3</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560675#M10487</link>
      <description>&lt;P&gt;yeah that will be the last solution. we have to justify to the business new order and then fix current production and keep same order new system i.e. SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 22:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-Left-Join-Different-default-order-of-observations-in-outputs/m-p/560675#M10487</guid>
      <dc:creator>kulbshar</dc:creator>
      <dc:date>2019-05-21T22:21:07Z</dc:date>
    </item>
  </channel>
</rss>

