Previous Page | Next Page

Optimizing Performance

Efficient Sorting

Consider Changing the Values of SORTPGM= and SORTCUTP=

SAS software includes an internal sort program that is often more efficient than host sort programs for sorting small volumes of data. Host sort programs are generally more efficient when the data volume is too high to perform the sort entirely in memory.

Under z/OS, the default value of the SAS system option SORTPGM= is BEST. This value causes SAS to use the SAS sort program for less than 4M of data; for more than 4M of data, SAS uses the host sort program. You use the SORTNAME= system option to specify the name of the host sort program.

The 4M limit is the default value that is specified by the SORTCUTP= system option, which is specific to z/OS. You might want to change the value of this option to optimize sorting for your particular applications.

Note:   Host sorts perform best when they know how many observations are to be sorted. In some circumstances, SAS don't know how many observations are in a data source. In these situations, SAS don't pass either the FILSZ= or SIZE= option to the host sort. The action that the host sort takes when one of these conditions occurs depends on the particular host sort that is being used.  [cautionend]

Take Advantage of the DFSORT Performance Booster

If your installation uses Release 13 or later of IBM's DFSORT as its host sort utility for large sorts, then you can take advantage of a DFSORT "performance booster." To do so, specify SORTBLKMODE in an OPTIONS statement, in the OPTIONS parameter list of the SAS cataloged procedure, or in a configuration file.

SORTBLKMODE causes SAS to work in conjunction with DFSORT to process your SAS sorting applications faster. SAS applications that use either PROC SORT or PROC SQL for sorting can take advantage of this performance booster. For large sorts of approximately 500,000 observations or more, CPU usage might be reduced by up to 25%.

Specify the Minimum Space for Sort Work Data Sets

Allocate the Minimum Space for Multiple Sorts

SAS uses the DYNALLOC system option to specify whether SAS or the host sort utility dynamically allocates the sort work data sets. If you specify the NODYNALLOC option, then SAS allocates the sort work data sets. If you specify the DYNALLOC option, then the host sort utility allocates the data sets. NODYNALLOC is the default setting for the DYNALLOC option.

When SAS allocates the sort work data sets, you need to ensure that you have adequate space allocated for your data sets. SAS attempts to allocate enough space for each sort work data set. If adequate space is not available, SAS issues a system error message.

The SORT= option specifies the minimum size of all allocated sort work data sets. You can use this option to ensure that you have enough allocated space to perform several sorts, especially if one or more of the sorts requires more space than the first sort. For example, you want SAS to allocate the space for the following sorts:


20 cylinders


50 cylinders


25 cylinders


200 cylinders

SAS uses the following process to allocate the space for each sort:
  1. Allocate 20 cylinders for the first sort.

  2. Free the space that it allocated for the previous sort because it needs more allocated space to perform the next allocation.

  3. Allocate 50 cylinders for the second sort.

  4. Reuse the allocated space for the third sort.

  5. Free the space that it allocated for the previous sort because it needs more allocated space to perform the next allocation.

  6. Allocate 200 cylinders to perform the fourth sort.

This process will work, and you will not be aware that it is happening, but it is not efficient.

It is more efficient to use the SORT= option to specify that SAS should allocate 200 cylinders for the first sort so that SAS can reuse the same space for all of the sorts. If you use the SORT= option, SAS does not have to free the allocated space before it allocates more space for the next sort.

Specify the SAS SORT Options

SAS uses the SORT= option to specify the minimum size of the sort work data sets if you specify the NODYNALLOC option, and you are using the host sort interface. You can also specify other options with the SORT= option to specify the type of unit, device, and so on, to use with the sort work data sets. The following list describes the function of each of the SAS system options that you can use when you specify the NODYNALLOC option:


specifies the minimum total size for all the data sets that are allocated dynamically. To calculate the primary space for each individual data set, SAS divides the value specified for the SORT= option by the number of sort files, and rounds up to the next whole number.


specifies the unit of allocation as cylinders, tracks, or blocks.


specifies the name of the unit device for the sort work file.


specifies which sort utility SAS uses.


specifies the prefix of the sort work data sets.


specifies how many sort work data sets to allocate.

Note:   You should not set the SAS system option SORTWKDD to a value of SORT (SORTWKDD=SORT), and you should not use ddnames prefixed with SORTWKDD=value to pre-allocate libraries or files in your JCL file. These two actions can result in subsequent PROC SORT failures in your SAS programs.  [cautionend]

Concurrent Sorting

SAS does not support concurrent host sorts. Attempting to invoke a host sort while one is already running causes SAS to revert to the internal sort, which might have an adverse effect on performance. Attempts to run concurrent sorts usually occur in a server environment, but running sorts in a server environment is not recommended.

Previous Page | Next Page | Top of Page