Troubleshooting "Sort initialization failure" and "Sort execution failure" errors in Windows and UNIX environments


The SAS® SORT and SQL procedures (PROC SORT and PROC SQL) might fail with these errors:

ERROR: Sort initialization failure.
ERROR: Sort execution failure.

Common reasons for these errors include the following:

Here are some troubleshooting tips to try when these errors occur.

Add the following statements before the code that produces the errors and review the SAS log for the option settings:

proc options group=memory; run;
proc options option=(work utilloc) value; run;
proc options option=threads; run;
options fullstimer msglevel=i ;

The FULLSTIMER option writes performance statistics, including memory usage, to the SAS log.
The MSGLEVEL=I option writes information to the SAS log about index processing and whether threaded sorts are being used.
If threaded sorts are being used, this note is written to the SAS log:

NOTE: SAS threaded sort was used

Important Note: When the THREADS option is enabled, temporary utility directories and files created by the threaded sort are created in the directory specified by the UTILLOC option. These temporary utility directories and files are not created until they are needed by the sort routine.

In rare cases, the "Sort initialization failure" error occurs because the submitting user ID does not have Read, Write, and Execute permissions for the WORK directory or the directory that is referenced by the UTILLOC option.

Additional Troubleshooting for UNIX/Linux

Verify that the SAS system option WORKPERMS is set appropriately.
To determine whether the current setting is in effect, submit the following statement:

proc options option=workperms; run;

Ensure that the UNIX umask settings for the submitting user ID have Read, Write, and Execute authority for the directory that is referenced by the UTILLOC option.

Using the same user id that is submitting the failing job, issue the UNIX command ulimit -a to determine whether the user ID has any system-imposed limits:    

    > ulimit -a
      time(cpu-seconds)    unlimited
      file(blocks)         unlimited
      coredump(blocks)     0
      data(kbytes)         2015464
      stack(kbytes)        10240
      lockedmem(kbytes)    64
      memory(kbytes)       unlimited
      nofiles(descriptors) 1024
      processes            10240 

If necessary, the UNIX systems administrator must make adjustments to the above settings.

Determining How Much Space Is Available for Sorts

Insufficient space in the directories referenced by the WORK and UTILLOC options can cause "Sort execution failure" errors because temporary utility files created during sorts are written to those locations. To determine the locations being used for WORK and UTILLOC, submit the following statement:

   proc options option=(work utilloc) value;

The locations being used for WORK and UTILLOC, along with information about how those options were set, will be written to the SAS log.

Monitor the amount of free space available in the directories used for temporary WORK and utility files.

If space is limited in these directories, you can use the cleanwork command to remove temporary files associated with defunct SAS processes. Refer to the documentation for the cleanwork command for UNIX or the cleanwork utility for Windows as appropriate.

Monitor the space consumed as the sorting process is executing to get an accurate view of the space used. Utility files are deleted after the sorting completes, so checking the amount of space available in the WORK or UTILLOC locations after the sort has completed can give the false impression that there is adequate space available.

Setting MEMSIZE and SORTSIZE Options

If the FULLSTIMER memory statistic for the failing step indicates that the amount of memory used is approximately equal to the current MEMSIZE setting, you should increase the value of the MEMSIZE option. In UNIX/Linux environments, the MEMSIZE option should be set to a reasonable numeric value, depending on the amount of RAM on the server. Refer to the documentation for the MEMSIZE option for UNIX or the MEMSIZE option for Windows as appropriate.