<?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: &amp;quot;not sorted in ascending sequence&amp;quot; error despite sorting that way in prior step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991484#M380337</link>
    <description>Thanks but no, that's not it. The error message claimed the *prior* nested sort hadn't worked. and had even yielded a differently sized data set!! (as SASKiwi noted.) The "rnd" is listed last, it's needed there, it's the item to be ranked in PROC RANK -- and this step had never malfunctioned before, in dozens and dozens of program runs-times-loop-iterations.&lt;BR /&gt;&lt;BR /&gt;Having re-run the same program on the same data without error this time, this now seems to me to have (indeed) been some kind of resource shortage/malfunction caused by running two demanding programs at the same time on my little pony of a PC.</description>
    <pubDate>Thu, 30 Jul 2026 03:57:42 GMT</pubDate>
    <dc:creator>thomasn528</dc:creator>
    <dc:date>2026-07-30T03:57:42Z</dc:date>
    <item>
      <title>"not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991471#M380330</link>
      <description>&lt;P&gt;I'm baffled by a "&lt;FONT color="#FF0000"&gt;data set X is not sorted&lt;/FONT&gt;" ERROR message.&amp;nbsp; Below is the relevant excerpt of the .LOG file showing (in my view) that the data involved *was* PROC SORTed in the exact way the subsequent PROC RANK step required.&amp;nbsp; The program involved has never generated this error before in processing similar data, and it only did in this particular iteration of the do-loop involved (loop 15 of 37).&amp;nbsp; The only "explanation" I can think of is that I was running 2 SAS programs concurrently on rather large data sets and maybe that affected program performance. But that isn't very convincing.&amp;nbsp; I'll re-run the program and see if it happens again when I'm not having the PC do anything else -- but whether or not the error re-occurs, I'll wonder why it ever occurred.&amp;nbsp; Can anyone suggest an explanation or a line of inquiry about this?&amp;nbsp; Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;MPRINT(MYSWAP): PROC SORT DATA=tmp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SYMBOLGEN: Macro variable CONSTRAINTVARS resolves to mh1_r start_status_org servseta agegroup gender race hispanic smised&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;MPRINT(MYSWAP): BY &lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;mh1_r start_status_org servseta agegroup gender race hispanic smised&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#000000"&gt;swap5&lt;/FONT&gt;&lt;FONT color="#000000"&gt; rnd&lt;/FONT&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;NOTE: There were 6636340 observations read from the data set WORK.TMP.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;NOTE: The data set WORK.TMP has 6636340 observations and 110 variables.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;real time 51.99 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;cpu time 24.14 seconds&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;MPRINT(MYSWAP): PROC RANK DATA=tmp OUT=tmpr;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SYMBOLGEN: Macro variable CONSTRAINTVARS resolves to mh1_r start_status_org servseta agegroup gender race hispanic smised&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;MPRINT(MYSWAP): BY &lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;mh1_r start_status_org servseta agegroup gender race hispanic smised&lt;/STRONG&gt;&lt;/FONT&gt; swap5 ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;MPRINT(MYSWAP): VAR rnd;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#FF0000"&gt;ERROR: Data set WORK.TMP is not sorted in ascending sequence. The current BY group has smised = 3 and the next BY group has smised = 2.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;NOTE: There were 997665 observations read from the data set WORK.TMP.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;&lt;FONT color="#339966"&gt;W&lt;/FONT&gt;&lt;FONT color="#008000"&gt;&lt;FONT color="#339966"&gt;AR&lt;/FONT&gt;NING: The data set WORK.TMPR may be incomplete. When this step was stopped there were 0 observations and 0 variables.&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#008000"&gt;WARNING: Data set WORK.TMPR was not replaced because this step was stopped.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;NOTE: PROCEDURE RANK used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;real time 6.63 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2" color="#0000FF"&gt;cpu time 0.35 seconds&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2026 21:19:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991471#M380330</guid>
      <dc:creator>thomasn528</dc:creator>
      <dc:date>2026-07-29T21:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991474#M380331</link>
      <description>&lt;P&gt;Take a look at these two notes:&lt;/P&gt;
&lt;P&gt;PROC SORT:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;NOTE: The data set WORK.TMP has 6636340 observations and 110 variables.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;PROC RANK:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;NOTE: There were 997665 observations read from the data set WORK.TMP.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I can only assume that the TMP data SORT processes is NOT the same as the TMP dataset RANK processes as the observation count doesn't match. Why would that be? Are we missing some processing between the SORT and the RANK?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2026 23:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991474#M380331</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2026-07-29T23:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991475#M380332</link>
      <description>&lt;P&gt;I would first confirm from the SAS log that there was not another step between those two that would have changed the dataset named WORK.TMP.&amp;nbsp; &amp;nbsp;Especially since the code seems to have been generated by a macro, so perhaps the macro had turned off the writing of notes to the SAS log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I would check what type of disk is being used for the WORK directory.&amp;nbsp; Perhaps there was some type of timing issue with write buffering on the disk.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You mentioned that you were running multiple programs, so make sure that each program is using a separate location for the WORK directory.&amp;nbsp; That should be the default, but it is possible to override the default when the SAS session is started.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2026 23:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991475#M380332</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-07-29T23:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991479#M380333</link>
      <description>&lt;P&gt;I noticed the difference between PROC SORT and PROC RANK:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;BY mh1_r start_status_org servseta agegroup gender race hispanic smised swap5 &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;rnd&lt;/STRONG&gt;&lt;/FONT&gt;;

BY mh1_r start_status_org servseta agegroup gender race hispanic smised swap5 ;&lt;/PRE&gt;
&lt;P&gt;try to remove 'rnd' in your proc sort.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that still does not work ,try option NOTSORTED:&lt;/P&gt;
&lt;PRE&gt;BY mh1_r start_status_org servseta agegroup gender race hispanic smised swap5    &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;notsorted&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jul 2026 03:01:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991479#M380333</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-07-30T03:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991480#M380334</link>
      <description>&lt;P&gt;No, there's no hidden/unlogged code between the PROC SORT and PROC RANK:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;%do v=1 %to 37;&amp;nbsp; &amp;nbsp;[...]&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;%if &amp;amp;ntoswap NE %then %do;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;DATA tmp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;CALL streaminit(98768976);&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;SET &amp;amp;outsw5;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;rnd = RAND("UNIFORM");&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier" size="2" color="#FF00FF"&gt;PROC SORT DATA=tmp; BY &amp;amp;constraintvars. swap5 rnd;&amp;nbsp; /*constraintvars are f(v)*/&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier" size="2" color="#FF00FF"&gt;PROC RANK DATA=tmp OUT=tmpr;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;BY &amp;amp;constraintvars. swap5 ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;VAR rnd;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;PROC SQL;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;[...]&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;%end;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;%end;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the fact that TMP has 2 different record counts at the 2 steps is distinctive, thank you.&amp;nbsp; That didn't happen for any other other iteration of the do-loop (which runs through dwindling lists of variables to sort and rank the records by).&amp;nbsp; It seems to confirm that "the machine got confused" by multiple versions of the TMP data set.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Since then I've re-run the code for the same input data and it ran without the error.&amp;nbsp; So I suspect that it had to do with using the same WORK space for concurrent SAS programs (even the other one didn't write a "competing' TMP data set).&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2026 03:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991480#M380334</guid>
      <dc:creator>thomasn528</dc:creator>
      <dc:date>2026-07-30T03:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991481#M380335</link>
      <description>&lt;P&gt;There was no intervening code.&amp;nbsp; I'm not sure how to check where a second SAS execution puts its WORK directory; I'd assumed it would be in the same place as the usual one (AppData/Local/Temp/SAS Temporary Files), maybe in a different "_TDblahblahSITELICENSE" subfolder. I guess sometime I'll run 2 long programs at the same time and see what I see.&lt;BR /&gt;&lt;BR /&gt;At any rate, when I re-ran the same code on the same input file, but without any other SAS program running, the program ran without error.&amp;nbsp; This time, TMP had the same number of records after PROC SORT as it did on intake by PROC RANK (see LOG file excerpt below, at the same point in program execution that failed earlier).&amp;nbsp; So I conclude: don't run 2 programs at once, at at least not 2 programs that work on relatively large data sets, at least not on my PC.&amp;nbsp; The one I just ran writes 17MB to the WORK file, the other one is probably similar.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier" size="2"&gt;MPRINT(MYSWAP): PROC SORT DATA=tmp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SYMBOLGEN: Macro variable CONSTRAINTVARS resolves to mh1_r start_status_org servseta agegroup gender race hispanic smised&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;MPRINT(MYSWAP): BY mh1_r start_status_org servseta agegroup gender race hispanic smised swap5 rnd;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;NOTE: There were &lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;6636340&lt;/FONT&gt;&lt;/STRONG&gt; observations read from the data set WORK.TMP.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;NOTE: The data set WORK.TMP has 6636340 observations and 110 variables.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;real time 45.70 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;cpu time 26.12 seconds&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;MPRINT(MYSWAP): PROC RANK DATA=tmp OUT=tmpr;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SYMBOLGEN: Macro variable CONSTRAINTVARS resolves to mh1_r start_status_org servseta agegroup gender race hispanic smised&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;MPRINT(MYSWAP): BY mh1_r start_status_org servseta agegroup gender race hispanic smised swap5 ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;MPRINT(MYSWAP): VAR rnd;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;NOTE: There were &lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;6636340&lt;/FONT&gt;&lt;/STRONG&gt; observations read from the data set WORK.TMP.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;NOTE: The data set WORK.TMPR has 6636340 observations and 110 variables.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;NOTE: PROCEDURE RANK used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;real time 32.38 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;cpu time 26.00 seconds&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2026 03:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991481#M380335</guid>
      <dc:creator>thomasn528</dc:creator>
      <dc:date>2026-07-30T03:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991482#M380336</link>
      <description>&lt;P&gt;If you can't reproduce the problem then I suggest you "park" it until it reappears&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2026 03:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991482#M380336</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2026-07-30T03:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991484#M380337</link>
      <description>Thanks but no, that's not it. The error message claimed the *prior* nested sort hadn't worked. and had even yielded a differently sized data set!! (as SASKiwi noted.) The "rnd" is listed last, it's needed there, it's the item to be ranked in PROC RANK -- and this step had never malfunctioned before, in dozens and dozens of program runs-times-loop-iterations.&lt;BR /&gt;&lt;BR /&gt;Having re-run the same program on the same data without error this time, this now seems to me to have (indeed) been some kind of resource shortage/malfunction caused by running two demanding programs at the same time on my little pony of a PC.</description>
      <pubDate>Thu, 30 Jul 2026 03:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991484#M380337</guid>
      <dc:creator>thomasn528</dc:creator>
      <dc:date>2026-07-30T03:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991485#M380338</link>
      <description>OK. Thanks for your help!</description>
      <pubDate>Thu, 30 Jul 2026 04:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991485#M380338</guid>
      <dc:creator>thomasn528</dc:creator>
      <dc:date>2026-07-30T04:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991506#M380340</link>
      <description>&lt;P&gt;That's a very weird error.&amp;nbsp; If you have time, I would actually try to reproduce it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simply having two separate SAS sessions running at the same time should not cause the error you showed, even if SAS runs out of resources.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;From your log it looks like the first PROC SORT step silently failed, which I've never seen happen in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using multiple concurrent SAS sessions should be fine.&amp;nbsp; Each session gets its own work library.&amp;nbsp; If you want to see the location of the work library, you can run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %sysfunc(pathname(work)) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Returns:&lt;/P&gt;
&lt;PRE&gt;1    %put %sysfunc(pathname(work)) ;
C:\Users\Quentin\AppData\Local\Temp\SAS Temporary Files\_TD20708_XXXX_
&lt;/PRE&gt;
&lt;P&gt;I just realized, the XXXX is the name of my computer.&amp;nbsp; So I guess on windows, the folder name is something like process ID and computer name.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2026 13:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991506#M380340</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2026-07-30T13:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991511#M380341</link>
      <description>I'll do that eventually, but not for at least the next week or two, too much to do. Thanks to you and everyone else for your interest and help!</description>
      <pubDate>Thu, 30 Jul 2026 14:50:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991511#M380341</guid>
      <dc:creator>thomasn528</dc:creator>
      <dc:date>2026-07-30T14:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991512#M380342</link>
      <description>&lt;P&gt;Disk overload is probably the reason then.&amp;nbsp; When SAS makes a new version of an existing dataset (like in your PROC SORT step) what it actually does is make a NEW file and then when the step finishes without error it deletes the old file and renames the file it just wrote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps in your case the second step started before the delete/rename actually modified the disk, so it opened the original unsorted dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the reduced number of observations read the the second step was just because it stopped reading when it noticed the sorting error.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2026 15:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991512#M380342</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-07-30T15:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991513#M380343</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Disk overload is probably the reason then.&amp;nbsp; When SAS makes a new version of an existing dataset (like in your PROC SORT step) what it actually does is make a NEW file and then when the step finishes without error it deletes the old file and renames the file it just wrote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps in your case the second step started before the delete/rename actually modified the disk, so it opened the original unsorted dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the reduced number of observations read the the second step was just because it stopped reading when it noticed the sorting error.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Put this is a PROC SORT step followed by a PROC RANK step in the same session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you actually seen a case where a following step started executing before the preceding step had completed executing?&amp;nbsp; I've never seen it happen.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2026 15:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991513#M380343</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2026-07-30T15:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991536#M380345</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/465536"&gt;@thomasn528&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks but no, that's not it. &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;The error message claimed the *prior* nested sort hadn't worked.&lt;/STRONG&gt; &lt;/FONT&gt;and had even yielded a differently sized data set!! (as SASKiwi noted.) The "rnd" is listed last, it's needed there, it's the item to be ranked in PROC RANK -- and this step had never malfunctioned before, in dozens and dozens of program runs-times-loop-iterations.&lt;BR /&gt;&lt;BR /&gt;Having re-run the same program on the same data without error this time, this now seems to me to have (indeed) been some kind of resource shortage/malfunction caused by running two demanding programs at the same time on my little pony of a PC.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The highlighted is not what the log shows. It says that the set that Proc Rank attempted to use did not match the required sort. Not that the sort hadn't worked. Pedantic perhaps but there is a difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macros and reusing of same data set names is always something to be a bit cautious of as a failure of one element can leave a data set from a previous run. I often remove "temporary" data sets at the end of a loop so this doesn't occur (and to keep disk space under control sometimes).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2026 03:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991536#M380345</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2026-07-31T03:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991581#M380359</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote in part:&amp;nbsp;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The highlighted is not what the log shows. It says that the set that Proc Rank attempted to use did not match the required sort. Not that the sort hadn't worked. Pedantic perhaps but there is a difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macros and reusing of same data set names is always something to be a bit cautious of as a failure of one element can leave a data set from a previous run. I often remove "temporary" data sets at the end of a loop so this doesn't occur (and to keep disk space under control sometimes).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But in this case reusing the same data set name could not be the cause of the issue.&amp;nbsp; The macro generates two consecutive proc statements:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA=tmp; BY &amp;amp;constraintvars. swap5 rnd;  /*constraintvars are f(v)*/

PROC RANK DATA=tmp OUT=tmpr;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log reports that the PROC SORT succeeded, and wrote the dataset named tmp.&amp;nbsp; The immediately subsequent PROC RANK step fails, and states that the dataset tmp is not sorted.&amp;nbsp; This is a mystery to me, unless PROC SORT somehow decided to sort the data using a different sortseq than PROC RANK expected.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2026 17:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991581#M380359</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2026-07-31T17:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991585#M380361</link>
      <description>&lt;P&gt;I think I overlooked another possible reason the code sequence failed during execution: during program execution, I shut the laptop, went to work, and opened it again, where it resumed work, seemingly without issue.&amp;nbsp; (I was and am under pressure to get some important data sets produced.)&lt;BR /&gt;&lt;BR /&gt;Perhaps the failure of PROC SORT to write all the required records to TMP (or the failure of PROC RANK to read all of the records from TMP), and the apparently associated failure to sort as expected, occurred exactly when/because of that risky behavior on my part.&amp;nbsp; The LOG rolled by too fast to notice anything at the time.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2026 18:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991585#M380361</guid>
      <dc:creator>thomasn528</dc:creator>
      <dc:date>2026-07-31T18:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991586#M380362</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/465536"&gt;@thomasn528&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I think I overlooked another possible reason the code sequence failed during execution: during program execution, I shut the laptop, went to work, and opened it again, where it resumed work, seemingly without issue.&amp;nbsp; (I was and am under pressure to get some important data sets produced.)&lt;BR /&gt;&lt;BR /&gt;Perhaps the failure of PROC SORT to write all the required records to TMP (or the failure of PROC RANK to read all of the records from TMP), and the apparently associated failure to sort as expected, occurred exactly when/because of that risky behavior on my part.&amp;nbsp; The LOG rolled by too fast to notice anything at the time.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But the log you posted in the question is the actual log from having this problem, right?&amp;nbsp; That log shows that the SORT succeeded but RANK failed.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2026 18:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991586#M380362</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2026-07-31T18:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: "not sorted in ascending sequence" error despite sorting that way in prior step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991607#M380363</link>
      <description>Yes, it's the actual log with the problem. I defer to you and others what exactly is shown by the log; certainly the error message happens during PROC RANK execution, but it refers to a failure of the data to "live up to" an expected sort order.&lt;BR /&gt;&lt;BR /&gt;I think the error -- in whichever PROC, no doubt RANK -- was likely a product of multiple unusual circumstances; it didn't reoccur when I avoided the issues I caused the first time.</description>
      <pubDate>Fri, 31 Jul 2026 19:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-not-sorted-in-ascending-sequence-quot-error-despite-sorting/m-p/991607#M380363</guid>
      <dc:creator>thomasn528</dc:creator>
      <dc:date>2026-07-31T19:17:30Z</dc:date>
    </item>
  </channel>
</rss>

