<?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: How to deal with nondeterministic results from PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793445#M254330</link>
    <description>&lt;P&gt;The not deterministic code is the code&amp;nbsp;&lt;EM&gt;you&lt;/EM&gt; fed to the interpreter. If you expect a certain order,&amp;nbsp;&lt;EM&gt;your&lt;/EM&gt; code has to &lt;EM&gt;force&lt;/EM&gt;&amp;nbsp;it, period. If a follow-up step (ie your PROC COMPARE) requires a specific order, set it.&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jan 2022 10:00:46 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-01-31T10:00:46Z</dc:date>
    <item>
      <title>How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/792063#M253787</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;we are dealing with an infrastructure change that is migrating our SAS environment from a Windows environment to a Linux environment while migrating procedures we handed up in having troubles in properly validate migration activities due to datasets that look to be different from a PROC COMPARE while being generated starting with the same code.&amp;nbsp; From the documentation below, it looks like sorting of the datasets could become nondeterministic in some circumstances, I'm wondering how this is usually handled.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0gwogdxntzooun1azrzwrwrqvzq.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0gwogdxntzooun1azrzwrwrqvzq.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 05:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/792063#M253787</guid>
      <dc:creator>mbertol4</dc:creator>
      <dc:date>2022-01-25T05:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/792121#M253797</link>
      <description>&lt;P&gt;Wherever a specific sort order is needed, properly written code has to explicitly force that order when a dataset is created.&lt;/P&gt;
&lt;P&gt;Since PROC COMPARE depends on the order, you need sorting and use ID when comparing datasets.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 08:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/792121#M253797</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-25T08:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/792140#M253805</link>
      <description>&lt;P&gt;The problem typically comes when you have duplicate keys in the tables. ORDER BY in SQL is indeterministic when there are duplicates of the ORDER variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The fast and dirty way to get around this is to use PROC SORT instead (or after the SQL extract), and sort by all variables, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=lib1.table2;
  by key date _ALL_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the variables are in the same order on the tables that you are trying to compare, that ought to do the trick.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 09:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/792140#M253805</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-01-25T09:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793372#M254282</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; I see detail on PROC SQL and not deterministic behavior is described in&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0gwogdxntzooun1azrzwrwrqvzq.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0gwogdxntzooun1azrzwrwrqvzq.htm&lt;/A&gt;&amp;nbsp; my doubts come from the fact essentially that in the SAS log there is no warning message generated when order by in the proc SQL is not deterministic.&amp;nbsp; I'm wondering why this potential issue is not properly highlighted in the log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 15:22:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793372#M254282</guid>
      <dc:creator>mbertol4</dc:creator>
      <dc:date>2022-01-30T15:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793375#M254284</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/302083"&gt;@mbertol4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&amp;nbsp; I see detail on PROC SQL and not deterministic behavior is described in&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0gwogdxntzooun1azrzwrwrqvzq.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0gwogdxntzooun1azrzwrwrqvzq.htm&lt;/A&gt;&amp;nbsp; my doubts come from the fact essentially that in the SAS log there is no warning message generated when order by in the proc SQL is not deterministic.&amp;nbsp; I'm wondering why this potential issue is not properly highlighted in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is not flagged as it is part of the basic definition of the SQL language.&amp;nbsp; It is a relational algebra for working on SETS.&amp;nbsp; A set does not have any order, just members.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 15:53:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793375#M254284</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-30T15:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793378#M254287</link>
      <description>&lt;P&gt;I see it's "&lt;SPAN&gt;basic definition of the SQL language&lt;/SPAN&gt;" but that has impacts on code portability.&amp;nbsp; Isn't it good programming practice to avoid not deterministic code ?&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 15:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793378#M254287</guid>
      <dc:creator>mbertol4</dc:creator>
      <dc:date>2022-01-30T15:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793383#M254289</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/302083"&gt;@mbertol4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I see it's "&lt;SPAN&gt;basic definition of the SQL language&lt;/SPAN&gt;" but that has impacts on code portability.&amp;nbsp; Isn't it good programming practice to avoid not deterministic code ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You picked that word to describe the behavior.&amp;nbsp; It is deterministic.&amp;nbsp; It returns the set of observations that match the program you gave.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 16:13:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793383#M254289</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-30T16:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793424#M254316</link>
      <description>&lt;P&gt;When we migrated from SAS 9.3 to SAS 9.4 we found that the PROC SQL result set order was sometimes different between the two versions, in the absence of an ORDER BY clause. Apparently enhancements to the SQL interpreter in 9.4 caused this. The simple addition of an explicit ORDER BY cured the problem, and ensured that our SAS 9.4 PROC SQL gave identical results to 9.3, including the result set order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 06:19:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793424#M254316</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-01-31T06:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793445#M254330</link>
      <description>&lt;P&gt;The not deterministic code is the code&amp;nbsp;&lt;EM&gt;you&lt;/EM&gt; fed to the interpreter. If you expect a certain order,&amp;nbsp;&lt;EM&gt;your&lt;/EM&gt; code has to &lt;EM&gt;force&lt;/EM&gt;&amp;nbsp;it, period. If a follow-up step (ie your PROC COMPARE) requires a specific order, set it.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 10:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793445#M254330</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-31T10:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793449#M254333</link>
      <description>&lt;P&gt;It depends on the data, not on the code itself; that's the reason why I was expecting some sort of warning message.&amp;nbsp; &amp;nbsp;As explained in&amp;nbsp; &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0gwogdxntzooun1azrzwrwrqvzq.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0gwogdxntzooun1azrzwrwrqvzq.htm&lt;/A&gt;&amp;nbsp; &lt;EM&gt;&amp;nbsp;"However, if the ORDER BY clause does not reference a joint combination of unique values, then the order of rows is not deterministic if ORDER BY is unstable."&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 10:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793449#M254333</guid>
      <dc:creator>mbertol4</dc:creator>
      <dc:date>2022-01-31T10:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to deal with nondeterministic results from PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793519#M254353</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/302083"&gt;@mbertol4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;EM&gt;"However, if the ORDER BY clause does not reference a joint combination of unique values, then the order of rows is not deterministic if ORDER BY is unstable."&lt;/EM&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Exactly. That's why it is YOUR duty to care for the correct order. And since the SQL step CAN do what you want (= what you tell it to do through your code) perfectly well, there's no need for a message. A WARNING or other message is only needed when the interpreter cannot exactly do what you tell it through the code (your &lt;EM&gt;expectations&lt;/EM&gt; are NOT part of any code).&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 14:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-deal-with-nondeterministic-results-from-PROC-SQL/m-p/793519#M254353</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-31T14:51:44Z</dc:date>
    </item>
  </channel>
</rss>

