<?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: Efficient sort of numeric arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909962#M358882</link>
    <description>&lt;P&gt;Like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;, I would use the CALL SORTN subroutine.&amp;nbsp; It works in a single data step, and sorting 50,000 numeric variables shouldn't add very much demand for memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And even if the quicksort algorithm were faster, you would need to include a lot more code (probably as a macro) than the single statement call sortn.&amp;nbsp; Given that your objective is to generate code that "&lt;SPAN&gt;can be published and is very general", you might be better off using the simplest SAS code possible.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 31 Dec 2023 01:46:41 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2023-12-31T01:46:41Z</dc:date>
    <item>
      <title>Efficient sort of numeric arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909944#M358872</link>
      <description>&lt;P&gt;Hi! I need to sort rather large arrays in the Data step. All Numeric values, unique. No. of values up to 50 thousand, perhaps more.&lt;/P&gt;
&lt;P&gt;Is Quicksort the best?&lt;/P&gt;
&lt;P&gt;Where can I find the best SAS code for Quicksort?&lt;/P&gt;
&lt;P&gt;What alternatives are there for Quicksort?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use SAS ODA (OnDemand for Academics). I want to write code that can be published and is very general.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Many thanks in advance!&lt;BR /&gt;(I have been googling for a white. Not easy to find the best answer)&lt;/P&gt;
&lt;P&gt;/Br AndersS&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 18:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909944#M358872</guid>
      <dc:creator>AndersS</dc:creator>
      <dc:date>2023-12-30T18:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient sort of numeric arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909948#M358873</link>
      <description>&lt;P&gt;Fifty thousand variables in a single observation? Really?&lt;/P&gt;
&lt;P&gt;Because otherwise an array makes no sense.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 19:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909948#M358873</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-12-30T19:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient sort of numeric arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909949#M358874</link>
      <description>&lt;P&gt;Hi! YES!&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;p.s.&lt;/P&gt;
&lt;P&gt;The limit in SAS ODA is around 250 million values.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 20:24:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909949#M358874</guid>
      <dc:creator>AndersS</dc:creator>
      <dc:date>2023-12-30T20:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient sort of numeric arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909950#M358875</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; My tendency would be to use CALL SORTN, which is designed for sorting numeric array members. I did find a reference to "QUICKSORT" in this older user group paper by Paul Dorfman &lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p096-26.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/sugi26/p096-26.pdf&lt;/A&gt; , however, I believe the paper may have pre-dated the introduction of CALL SORTN.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You may be limited by memory as to the size of the array, this previous forum thread discusses memory as a limiting factor in array size &lt;A href="https://communities.sas.com/t5/SAS-Programming/what-s-the-limit-to-how-many-elements-variables-a-SAS-array-can/td-p/499675" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/what-s-the-limit-to-how-many-elements-variables-a-SAS-array-can/td-p/499675&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'm sure that others with more experience sorting arrays will have additional feedback.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Dec 2023 21:28:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909950#M358875</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2023-12-30T21:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient sort of numeric arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909957#M358877</link>
      <description>&lt;P&gt;Transpose the data and use PROC SORT.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2023 00:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909957#M358877</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-31T00:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient sort of numeric arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909962#M358882</link>
      <description>&lt;P&gt;Like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;, I would use the CALL SORTN subroutine.&amp;nbsp; It works in a single data step, and sorting 50,000 numeric variables shouldn't add very much demand for memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And even if the quicksort algorithm were faster, you would need to include a lot more code (probably as a macro) than the single statement call sortn.&amp;nbsp; Given that your objective is to generate code that "&lt;SPAN&gt;can be published and is very general", you might be better off using the simplest SAS code possible.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 31 Dec 2023 01:46:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/909962#M358882</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-12-31T01:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient sort of numeric arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/910104#M358950</link>
      <description>&lt;P&gt;Hi! I have made some tests on the Linux server for SAS ODA.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; I used PROC NLIN – quadratic model.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; CPU in seconds for CALL SORTN.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; SIZE in millions of array elements.&lt;/P&gt;
&lt;P&gt;(Good with all the examples in SAS Documentation. Just cut-and-paste)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&amp;nbsp; An almost straight line. &lt;BR /&gt;Sorting methods are often linear (like BigOrdo (N*log (N))&amp;nbsp; for "small models"&lt;/P&gt;
&lt;P&gt;and more quadratic (like BigOrdo(N*N))&amp;nbsp;&amp;nbsp;for "large models".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AndersS_0-1704212818873.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92170iD470A21E3413EE1F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AndersS_0-1704212818873.png" alt="AndersS_0-1704212818873.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 16:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Efficient-sort-of-numeric-arrays/m-p/910104#M358950</guid>
      <dc:creator>AndersS</dc:creator>
      <dc:date>2024-01-02T16:32:49Z</dc:date>
    </item>
  </channel>
</rss>

