<?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: sortedby= in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sortedby/m-p/228233#M41208</link>
    <description>&lt;P&gt;Thanks for the info.&amp;nbsp; It took an hour and two minutes to run.&amp;nbsp; I just added a by statement and am running it again.&amp;nbsp; I'll reply again if there is any improvement.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Oct 2015 16:12:58 GMT</pubDate>
    <dc:creator>Steelers_In_DC</dc:creator>
    <dc:date>2015-10-02T16:12:58Z</dc:date>
    <item>
      <title>sortedby=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sortedby/m-p/228224#M41204</link>
      <description>&lt;P&gt;I'm searching a large dataset for a specific zip code.&amp;nbsp; I have this dataset sorted by prop_zip_code which is 9 digits, there is another field us_zip5 that it is not sorted on.&amp;nbsp; (next month I will sort on both)&amp;nbsp; If I add sortedby in the set statement does this option tell SAS to treat the search as if it is sorted by us_zip5?&amp;nbsp; I cannot find any clear documentation on that, any clarification or other suggestions for speed are appreciated:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data buckingham;&lt;BR /&gt;set mdj.monthly_1mm_zips_sort(sortedby=us_zip5);&lt;BR /&gt;where us_zip5 = '18912';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 15:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sortedby/m-p/228224#M41204</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-10-02T15:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: sortedby=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sortedby/m-p/228227#M41205</link>
      <description>&lt;P&gt;I don't believe that Sortedby is going to have any speed&amp;nbsp;effect on an input data set though it may have an impact on a BY statement. The option is used to set the indicator stored in the dataset for sort order and would be useful for an output set. Normally a data step has no guarantee of what the output order might be but if you have made sure the data is in a specific order setting the option on the output data set would speed things that examine sort order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 15:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sortedby/m-p/228227#M41205</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-02T15:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: sortedby=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sortedby/m-p/228233#M41208</link>
      <description>&lt;P&gt;Thanks for the info.&amp;nbsp; It took an hour and two minutes to run.&amp;nbsp; I just added a by statement and am running it again.&amp;nbsp; I'll reply again if there is any improvement.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 16:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sortedby/m-p/228233#M41208</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-10-02T16:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: sortedby=</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sortedby/m-p/228247#M41212</link>
      <description>&lt;P&gt;Although SORTEDBY will not help, if your data set is in order, you are allowed to use a BY statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data buckingham;&lt;BR /&gt;set mdj.monthly_1mm_zips_sort;&lt;BR /&gt;where us_zip5 = '18912';&lt;/P&gt;&lt;P&gt;by us_zip5;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It doesn't matter whether PROC SORT performed the sorting or not, it only matters that the observations are in order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This in itself will not speed up the process, but it may set the stage for other experimentation. &amp;nbsp;For example, you could try:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data buckingham;&lt;BR /&gt;set mdj.monthly_1mm_zips_sort;&lt;BR /&gt;where us_zip5 = '18912';&lt;/P&gt;&lt;P&gt;by us_zip5;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;if last.us_zip5 then stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the WHERE statement saves the software from reading observations into the PDV. &amp;nbsp;But the software still has to search through blocks of data (not read into the PDV) to check for additional "18912" observations. &amp;nbsp;So adding the STOP logic saves the software from having to search through remaining blocks of data. &amp;nbsp;The savings really depend on how far into the data "18912" appears, but you should be able to measure it and it might be considerable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let us know what you discover.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 18:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sortedby/m-p/228247#M41212</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-10-02T18:29:25Z</dc:date>
    </item>
  </channel>
</rss>

