<?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: Sorting Variables with Missing Values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Sorting-Variables-with-Missing-Values/m-p/46881#M12511</link>
    <description>Thank you so much Daniel.  Your explanation was very clear and everything worked perfectly.&lt;BR /&gt;
&lt;BR /&gt;
Greatly appreciated.</description>
    <pubDate>Sun, 21 Jun 2009 22:50:57 GMT</pubDate>
    <dc:creator>Scottcom4</dc:creator>
    <dc:date>2009-06-21T22:50:57Z</dc:date>
    <item>
      <title>Sorting Variables with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sorting-Variables-with-Missing-Values/m-p/46878#M12508</link>
      <description>Hi All,&lt;BR /&gt;
&lt;BR /&gt;
I am trying to sort using SQL (as I am reading the data in from an oracle database and this appears to be the most efficient method), however it sorts blanks last.  As a result I get:&lt;BR /&gt;
&lt;BR /&gt;
1&lt;BR /&gt;
2&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Where as with Proc Sort I get:&lt;BR /&gt;
&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
1&lt;BR /&gt;
2&lt;BR /&gt;
&lt;BR /&gt;
Does anyone know a way to have Proc SQL sort in the same way that Proc Sort does?&lt;BR /&gt;
&lt;BR /&gt;
Thank you for your help.</description>
      <pubDate>Fri, 19 Jun 2009 06:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sorting-Variables-with-Missing-Values/m-p/46878#M12508</guid>
      <dc:creator>Scottcom4</dc:creator>
      <dc:date>2009-06-19T06:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Variables with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sorting-Variables-with-Missing-Values/m-p/46879#M12509</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Please try this&lt;BR /&gt;
&lt;BR /&gt;
data x;&lt;BR /&gt;
input a;&lt;BR /&gt;
cards;&lt;BR /&gt;
1&lt;BR /&gt;
2&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table x1 as&lt;BR /&gt;
select *&lt;BR /&gt;
from x&lt;BR /&gt;
order by a;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Rgds,&lt;BR /&gt;
skm</description>
      <pubDate>Fri, 19 Jun 2009 08:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sorting-Variables-with-Missing-Values/m-p/46879#M12509</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-19T08:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Variables with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sorting-Variables-with-Missing-Values/m-p/46880#M12510</link>
      <description>Trouble is MISSING/NULLS have different meanings for ORACLE and SAS.&lt;BR /&gt;
&lt;BR /&gt;
When you perform an Order by through SQL Pass-Through (on the ORACLE side), it seems NULLS are considered a very big number.&lt;BR /&gt;
When you perform a SAS SORT, MISSINGS are considered a very little number.&lt;BR /&gt;
&lt;BR /&gt;
Have you tried to order through a COALESCE function?&lt;BR /&gt;
&lt;BR /&gt;
ORDER BY COALESCE (COL, -1)&lt;BR /&gt;
&lt;BR /&gt;
The COALESCE function causes any results that are NULL to be replaced by some other value you wish (in the example, -1).&lt;BR /&gt;
&lt;BR /&gt;
Not a pretty solution, but a easy one that may do what you whish.&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>Fri, 19 Jun 2009 09:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sorting-Variables-with-Missing-Values/m-p/46880#M12510</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-06-19T09:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Variables with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Sorting-Variables-with-Missing-Values/m-p/46881#M12511</link>
      <description>Thank you so much Daniel.  Your explanation was very clear and everything worked perfectly.&lt;BR /&gt;
&lt;BR /&gt;
Greatly appreciated.</description>
      <pubDate>Sun, 21 Jun 2009 22:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Sorting-Variables-with-Missing-Values/m-p/46881#M12511</guid>
      <dc:creator>Scottcom4</dc:creator>
      <dc:date>2009-06-21T22:50:57Z</dc:date>
    </item>
  </channel>
</rss>

