<?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 sorted but  data is NOTsorted in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21026#M3337</link>
    <description>I've stumbled on this before.&lt;BR /&gt;
&lt;BR /&gt;
I was extracting data from a DB2 system (zOS) to SAS on a distributed system (AIX).&lt;BR /&gt;
The sort sequence did not match.&lt;BR /&gt;
&lt;BR /&gt;
Since there were no predefined SORTSEQ that suited my needs, I've solved this trouble by creating a new SORT sequence (matching tho one at DB2) and setting the system option SORTSEQ to this table in the autoexec file.&lt;BR /&gt;
&lt;BR /&gt;
No more problems since then.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps.&lt;BR /&gt;
&lt;BR /&gt;
See the TRANTAB procedure to create you own sequence table:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/a000146227.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/a000146227.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
And check the SORTSEQ system option:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/a000279219.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/a000279219.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
    <pubDate>Mon, 23 Nov 2009 17:53:56 GMT</pubDate>
    <dc:creator>DanielSantos</dc:creator>
    <dc:date>2009-11-23T17:53:56Z</dc:date>
    <item>
      <title>SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21025#M3336</link>
      <description>hit a problem with PROC SQL sorting &lt;BR /&gt;
after pulling some data together with proc sql, I ran a short data step to check for duplicate names and found the table was NOT sorted by the column in the "ORDER BY schemeName" clause.[pre]513  proc sql  ;&lt;BR /&gt;
514      create table sch_names_low as&lt;BR /&gt;
515            select a.psrNumber, a.schemeName, b.statusdate, b.status&lt;BR /&gt;
516              from mi.tbl_bau_stats_details a&lt;BR /&gt;
517              join mi.tbl_bau_stats_valuations b&lt;BR /&gt;
518                on a.psrNumber = b.psrNumber&lt;BR /&gt;
519             where schemeName lt  'a'&lt;BR /&gt;
520      &lt;B&gt;    order by schemeName&lt;/B&gt;&lt;BR /&gt;
521                  ;&lt;BR /&gt;
NOTE: Table WORK.SCH_NAMES_LOW created, with 258 rows and 4 columns.&lt;BR /&gt;
&lt;BR /&gt;
522  quit ;&lt;BR /&gt;
NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;
      real time           0.25 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
523&lt;BR /&gt;
524  data schn_dup ;&lt;BR /&gt;
525    set  ;&lt;BR /&gt;
526   &lt;B&gt; by schemeName  ;&lt;/B&gt;&lt;BR /&gt;
527    if first.schemeName &amp;amp; last.schemeName then delete ;&lt;BR /&gt;
528  run;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: &lt;B&gt;BY variables are not properly sorted &lt;/B&gt;on data set WORK.SCH_NAMES_LOW.&lt;BR /&gt;
PSRNumber=10###### SchemeName=[c&amp;amp; S (Neatxxxxxxxxxxxxxxxxxxxxxx Scheme 155EP373 StatusDate=04JAN2005:00:00:00 Status=Wound Up FIRST.SchemeName=1 LAST.SchemeName=1 _ERROR_=1 _N_=3&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
NOTE: There were 4 observations read from the data set WORK.SCH_NAMES_LOW[/pre]&lt;BR /&gt;
&lt;BR /&gt;
No amount of SORTSEQ= handling could resolve the problem.&lt;BR /&gt;
&lt;BR /&gt;
Usage note 4999 &lt;A href="http://support.sas.com/kb/4/999.html" target="_blank"&gt;http://support.sas.com/kb/4/999.html&lt;/A&gt; hints at the problem. These data come from sql server where [ appears to have a different sort value than in SAS![pre]571  data _null_ ;&lt;BR /&gt;
572  set SCH_NAMES_LOW( obs=4) ;&lt;BR /&gt;
573  put schemeName= $char5. schemeName $hex10. ;&lt;BR /&gt;
574  run;&lt;BR /&gt;
&lt;BR /&gt;
SchemeName="J" F 224A222046&lt;BR /&gt;
SchemeName=(C M) 2843204D29&lt;BR /&gt;
SchemeName=[c&amp;amp; S 5B63262053&lt;BR /&gt;
SchemeName=03666 3033363636&lt;BR /&gt;
NOTE: There were 4 observations read[/pre]&lt;BR /&gt;
Helpfully, PROC SQL did not mark the table created (with ORDER BY) as sorted, when the sort was performed on the SQL Server. &lt;BR /&gt;
However, Proc SQL might inform and properly warn with some MSGLEVEL=i message or WARNING .&lt;BR /&gt;
 &lt;BR /&gt;
Is there some option I have missed which creates this warning?</description>
      <pubDate>Mon, 23 Nov 2009 17:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21025#M3336</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-23T17:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21026#M3337</link>
      <description>I've stumbled on this before.&lt;BR /&gt;
&lt;BR /&gt;
I was extracting data from a DB2 system (zOS) to SAS on a distributed system (AIX).&lt;BR /&gt;
The sort sequence did not match.&lt;BR /&gt;
&lt;BR /&gt;
Since there were no predefined SORTSEQ that suited my needs, I've solved this trouble by creating a new SORT sequence (matching tho one at DB2) and setting the system option SORTSEQ to this table in the autoexec file.&lt;BR /&gt;
&lt;BR /&gt;
No more problems since then.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps.&lt;BR /&gt;
&lt;BR /&gt;
See the TRANTAB procedure to create you own sequence table:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/a000146227.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/a000146227.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
And check the SORTSEQ system option:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/a000279219.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/a000279219.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Mon, 23 Nov 2009 17:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21026#M3337</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-11-23T17:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21027#M3338</link>
      <description>thank you Daniel&lt;BR /&gt;
I'll try that again&lt;BR /&gt;
 &lt;BR /&gt;
peter.c</description>
      <pubDate>Mon, 23 Nov 2009 23:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21027#M3338</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-23T23:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21028#M3339</link>
      <description>What are these tables:&lt;BR /&gt;
Mi.tbl_bau_stats_details&lt;BR /&gt;
Mi.tbl_bau_status_valuations?&lt;BR /&gt;
&lt;BR /&gt;
Are they SAS tables?&lt;BR /&gt;
&lt;BR /&gt;
I had the same problems when using oracle data.&lt;BR /&gt;
Workaround was done then downloaded data, then used proc sql; &lt;BR /&gt;
After this data was sorted.</description>
      <pubDate>Tue, 24 Nov 2009 11:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21028#M3339</guid>
      <dc:creator>SAS_user</dc:creator>
      <dc:date>2009-11-24T11:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21029#M3340</link>
      <description>SAS user&lt;BR /&gt;
&lt;BR /&gt;
sorry the message was so long, that you missed &lt;BR /&gt;
&amp;gt; These data come from sql server where [&lt;BR /&gt;
 &lt;BR /&gt;
At least this scenario is a little better than my previous experience in this area.  &lt;BR /&gt;
Then, a cimport of a sas table downloaded to windows from zOS, continued to provide sortedby information - including sortseq=ebcdic. That was ignored in proc sql sas913 - so sql joined with no errors when the first row in the table downloaded from zOS was higher than all rows in the other table and both tables were declared to be in the corresponding order (apart from the sortseq=ebcdic on the table from zOS).&lt;BR /&gt;
At least in this scenario, the implicit pass-thru of the query including the "ORDER BY" clause, by the sas/access to odbc engine connected to sql server, results in &lt;I&gt;no&lt;/I&gt; sortedby information being placed in the header of the output data set.&lt;BR /&gt;
&lt;BR /&gt;
 So I've removed that order-by clause, and plan not to use it where ever I'm pulling data through pass-thru sql. &lt;BR /&gt;
I still think proc sql could generate a warning when the effect of order-by is outside the interpretation of SAS.&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Tue, 24 Nov 2009 19:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/21029#M3340</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-11-24T19:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/494722#M130430</link>
      <description>&lt;P&gt;While I agree that sortseq is related, I think SAS need to make a change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;So lets take&amp;nbsp;an SQL Server database table.&amp;nbsp;The collation is&amp;nbsp;Latin1_General_CI_AS as expected&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue of course is that if you read&amp;nbsp;it into SAS via a &lt;SPAN&gt;PROC&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;SORT&lt;/SPAN&gt;, (irrespective of FORCE as an option) SAS hands it over to the database due to the SORTPGM option.&amp;nbsp;If you run "proc options option=sortpgm value; run;" you will likely see SORTPGM=BEST&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As Lex noted in&amp;nbsp;&lt;A href="http://support.sas.com/resources/papers/proceedings09/141-2009.pdf&amp;nbsp;" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/141-2009.pdf&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;you can change that to "options sortpgm=SAS;" which will make SAS do the sort with its defaults.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From time to time I see customers reading tables into SAS first then sorting which is not efficient, and this info is not jumping out around the place - so what&amp;nbsp;about this?&lt;/P&gt;
&lt;P&gt;1.) It would be nicer if PROC SORT allowed the SORTPGM option to be specified on the PROC SORT statement, not only as a system option. This would place it 'obvious' in the list of documented PROC SORT options&lt;/P&gt;
&lt;P&gt;2.)&amp;nbsp;&lt;SPAN&gt;In the meantime it would be good if&amp;nbsp;SAS added this kind of information to the PROC SORT statement doco page anyway, with links to&amp;nbsp;relevant SAS Access RDBMS doco, then anyone hitting this issue (collating and sortpgm) would quickly find the better answer (sortpgm). Its all good and well for those of us who know it, but I would like it to be accessible&amp;nbsp;knowledge for all customers. &lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 06:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/494722#M130430</guid>
      <dc:creator>broz</dc:creator>
      <dc:date>2018-09-12T06:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/494731#M130436</link>
      <description>&lt;P&gt;Hi Peter,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I work with SQL Server extensively in my current role, and have had a round with SAS TS on this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the collation sequence of your SQL Server table?&amp;nbsp; Actually, it's the collation sequence of your sort column schemeName; a collation sequence can be set at the column level in SQL Server.&amp;nbsp; Which took me a while to wrap my head around!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In&amp;nbsp;SQL Server Management Studio:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT *
FROM   [INFORMATION_SCHEMA].[COLUMNS] [c]
WHERE  [c].[TABLE_NAME]='table_name'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the COLLATION_NAME is NULL, then the column inherits the collation sequence of the database:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT *
FROM   sys.[databases]
WHERE  name='your_database'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS uses a case-sensitive collation sequence.&amp;nbsp; If your column has a case-insensitive collation sequence, that is likely your problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Issue the command:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options sastrace=',,,d' sastraceloc=saslog nostsuffix; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in your program to see if SAS implicitly passed through the&amp;nbsp;ORDER BY to SQL Server for execution.&amp;nbsp; I suspect it did.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have the right permissions, you *could* assign a different collation sequence (eg. Latin1_General_BIN) to that column.&amp;nbsp; But you better make sure it doesn't mess up other work by your colleagues!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise, you could change your code to have SAS do the sorting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   connect using mi;
   create table sch_names_low as
   select a.psrNumber, a.schemeName, b.statusdate, b.status
   from connection to mi (
select a.psrNumber, a.schemeName, b.statusdate, b.status
from   tbl_bau_stats_details a
join   tbl_bau_stats_valuations b
on     a.psrNumber = b.psrNumber
where  schemeName lt 'a'
   )
   order by schemeName
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think you'll be in a world of pain if you try to create a custom trantab that matches your SQL Server collation sequence.&amp;nbsp; But let me know if you go down that track and get it to work &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The conclusion we came up with after consultation with SAS TS was that we changed the collation sequence of our databases from the default case-insensitive one (IIRC Latin1_General_100_CI_AI) to a case-sensitive one that matches SAS's sort order (Latin1_General_BIN).&amp;nbsp; (This was in conjunction with a rebuild/upgrade of our SQL Server).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That change has its own issues (eg. case-sensitive table and column names), and bugs in SAS where SAS decides to uppercase implicit pass-through code to the database, and thinks that table FooBar is FOOBAR, and SQL Server returns that the table doesn't exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 00:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/494731#M130436</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-01-08T00:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/495096#M130603</link>
      <description>&lt;P&gt;Hi Peter,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One more thing I thought of.&amp;nbsp; You can actually specify the desired collation sequence on the ORDER BY statement in T-SQL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some example code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF OBJECT_ID('tempdb..#T1') IS NOT NULL DROP TABLE #T1

CREATE TABLE #T1 (
    MyVar VARCHAR(3) COLLATE Latin1_General_100_CI_AI NOT NULL
)

INSERT INTO [#T1] 
([MyVar])
VALUES
('FOO'),('Foo'),('foo'),('fOo'),('fOO'),('FoO')

SELECT * FROM #T1 ORDER BY MyVar
SELECT * FROM #T1 ORDER BY MyVar COLLATE Latin1_General_BIN&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Run the above code in SQL Server Management Studio and note the different output from the two select statements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, run this SAS code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%libname_sqlsvr(libref=TMP,server=YourSQLServer,port=,database=tempdb,schema=dbo)

proc sql;
   connect using tmp;
   execute by    tmp (
IF OBJECT_ID('tempdb..#T1') IS NOT NULL DROP TABLE #T1

CREATE TABLE #T1 (
    MyVar VARCHAR(3) COLLATE Latin1_General_100_CI_AI NOT NULL
)

INSERT INTO [#T1] 
([MyVar])
VALUES
('FOO'),('Foo'),('foo'),('fOo'),('fOO'),('FoO')
   );

   create table test1 as
   select * from connection to tmp (
SELECT * FROM #T1 ORDER BY MyVar
   );

   create table test2 as
   select * from connection to tmp (
SELECT * FROM #T1 ORDER BY MyVar COLLATE Latin1_General_BIN
   );
quit;

data _null_;
   set test1; * fails, the default column collation sequence is case-insensitive ;
   by MyVar;
run;

data _null_;
   set test2; * works, the explicit collation sequence is case-sensitive and matches SAS ;
   by MyVar;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I doubt that it's possible to coax SAS to implicitly pass-through a collation sequence&amp;nbsp;to the SQL Server ORDER BY clause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, if you can change your code to use explicit pass-through, the 2nd approach may work for you.&amp;nbsp; You'd likely get better performance having SQL Server do the sorting first, rather than having SAS do the sorting as in my previous post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH...&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 00:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/495096#M130603</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2018-09-13T00:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/525281#M142920</link>
      <description>&lt;P&gt;Spot on Scott. Yes that's pretty much where we ended up before commenting on this thread. Using the TSQL option COLLATE override was okay but the prospect of changing lots of code plus the (probable) extra overhead on the database to override each field's collate definition did not excite us.&lt;/P&gt;
&lt;P&gt;In the end the database team changed the database collating default as well as some field collate values - which added the problem of working out if it was intentionally different - or whether it was an artifact of the legacy non SAS tools that loaded the database. Its a bit of a tar ball.&lt;/P&gt;
&lt;P&gt;Coming back to the change suggested, irrespective of the COLLATE option and values chosen in the database, I emphatically think SAS should put some breadcrumbs down for SAS users to follow, starting with a specific new option on PROC SORT that does what the sortpgm option. From a human interface design perspective, the user is deal with a SORT so will look at the SORT doco, and if the sortpgm option was there then the discourse can also explain that not only does it ensure SAS sorts the data, it can override a database collate sequence. This is important because it informs the users in a natural 'discovery' pathway.&lt;/P&gt;
&lt;P&gt;As for the efficiency, a novice user is likely to read the table out of the database, then sort it with SAS once it is in a SAS dataset. This means an inefficient two pass of the data. At least if a sortpgm option was available on proc sort syntax, the users would at least gain the efficiency of one pass of the data as its read from the database.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 23:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/525281#M142920</guid>
      <dc:creator>broz</dc:creator>
      <dc:date>2019-01-07T23:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/525291#M142926</link>
      <description>&lt;P&gt;Sure, there are many examples where you can override a system option with a runtime override (for example OBS).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps create a post in SASware Ballot Ideas and lobby to get folks to upvote it?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 00:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/525291#M142926</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-01-08T00:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sorted but  data is NOTsorted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/525304#M142932</link>
      <description>&lt;P&gt;If going for implicit SQL then you could of course also create a SAS view instead of a table and then use this view in a SAS Proc Sort.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 01:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-sorted-but-data-is-NOTsorted/m-p/525304#M142932</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-01-08T01:20:39Z</dc:date>
    </item>
  </channel>
</rss>

