SORT Procedure: z/OS

Sorts observations in a SAS data set by one or more variables, then stores the resulting sorted observations in a new SAS data set or replaces the original data set.
z/OS specifics: Available z/OS sort utilities and SORT procedure statement options; host-specific SAS system options

Details

PROC SORT

You can direct the SORT procedure to use either the SAS sort program, which is available under z/OS and under all other operating environments, or a sort utility that is specific to z/OS. You can also use the SORTPGM= system option to choose the best sort program to use. For more information, see SORTPGM= System Option: z/OS.
The following SAS system options also affect any sorting that is done by SAS:
DYNALLOC
SORTEQOP
SORTSHRB
FILSZ
SORTLIB=
SORTSIZE=1
SORT=
SORTLIST
SORTSUMF
SORTALTMSGF
SORTMSG
SORTUADCON
SORTBLKMODE
SORTMSG=
SORTUNIT=
SORTBUFMOD
SORTNAME=
SORTWKDD=
SORTCUTP=
SORTOPTS
SORTWKNO=
SORTDEV=
SORTPARM=
SORT31PL
SORTDEVWARN
SORTPGM=
SORTDUP=1
SORTSEQ=1
1This option is either portable or portable with host specifics. For information about these options, begin with SAS System Options: Reference.
You can see the values of the preceding options by submitting:
proc options group=sort; run;

PROC SORT Statement Options

The following host-specific sort options are available in the PROC SORT statement under z/OS in addition to the statement options that are available under all host operating environments. The list includes the portable EQUALS option because it has aspects that are specific to z/OS.
DIAG
passes the DIAG parameter to the sort utility. If the utility supports this option, then it produces additional diagnostic information if the sort fails.
EQUALS
passes the EQUALS parameter to the sort utility program whether the sort utility supports it. SAS software defaults to EQUALS by passing the parameter to the utility if the SAS system option SORTEQOP is in effect.
LEAVE=n
specifies how many bytes to leave unallocated in the region. Occasionally, the SORT procedure runs out of main storage. If main storage is exceeded, rerun the job and increase the LEAVE= value (which has a default value of 16000) by 30000.
Note: The LEAVE option applies only if SORTSIZE=SIZE is specified.
LIST | L
provides additional information about the system sort. Not all sort utilities support the specification of the LIST option; they might require that it be specified when the sort utility is generated or installed. This option is the default action if the SAS system option SORTLIST is in effect. Also, this option overrides NOSORTLIST if it is in effect.
MESSAGE | M
prints a summary of the system sort utility's actions. This option is the default action if the SAS system option SORTMSG is in effect. Also, this option overrides NOSORTMSG if it is in effect. MESSAGE is useful if you run PROC SORT and the SAS log prints a message indicating that the sort did not work properly. Explanations of the message can be found in the IBM or vendor reference manual that describes your system sort utility.
SORTSIZE=n | nK | nM | nG | MAX | SIZE
specifies the maximum virtual storage that can be used by the system sort utility. If not specified, the default sort size is given by the SAS system option SORTSIZE=.
SORTWKNO=n
specifies how many sort work areas PROC SORT allocates. If a value is not specified, the default is given by the SAS system option SORTWKNO=. The range for SORTWKNO is 0-99.
TECHNIQUE=xxxx | T=xxxx
specifies a four-character sort technique to be passed to the system sort utility. SAS does not check the validity of the specified value, so you must ensure that it is correct.

Specifying the SORTSEQ= Option with a Host Sort Utility

The SORTSEQ= option enables you to specify the collating sequence for your sort. For more information, see “SORTSEQ= System Option: UNIX, Windows, and z/OS” in the SAS National Language Support (NLS): Reference Guide.
CAUTION:
If you are using a host sort utility to sort your data, then specifying the SORTSEQ= option might corrupt the character BY variables if the sort sequence translation table and its inverse are not one-to-one mappings.
In other words, for the sort to work the translation table must map each character to a unique weight, and the inverse table must map each weight to a unique character variable.
If your translation tables do not map one-to-one, then you can use one of the following methods to perform your sort:
  • create a translation table that maps one-to-one. Once you create a translation table that maps one-to-one, you can easily create a corresponding inverse table using the TRANTAB procedure. If your table is not mapped one-to-one, then you will receive the following note in the SAS log when you try to create an inverse table:
    NOTE:  This table cannot be mapped one to one.
    For more information, see “The TRANTAB Procedure” in the SAS National Language Support (NLS): Reference Guide.
  • use the SAS sort. You can specify the SAS sort using the SORTPGM system option. For more information, see SORTPGM= System Option: z/OS.
  • specify the collation order options of your host sort utility. See the documentation for your host sort utility for more information.
  • create a view with a dummy BY variable. For an example, see “Creating a View with a Dummy BY Variable” below.
Note: After using one of these methods, you might need to perform subsequent BY processing using either the NOTSORTED option or the NOBYSORTED system option. For more information about the NOTSORTED option, see “BY Statement” in the SAS Statements: Reference. For more information about the NOBYSORTED system option, see “BYSORTED System Option” in the SAS System Options: Reference.

Example: Creating a View with a Dummy BY Variable

The following code is an example of creating a view using a dummy BY variable:
options sortpgm=host msglevel=i;
data one;
   input name $ age;
datalines;
anne 35
ALBERT 10
JUAN 90
janet 5
bridget 23
BRIAN 45
;
data oneview / view=oneview;
   set one;
   name1=upcase(name);
run;
proc sort data=oneview out=final(drop=name1);
   by name1;
run;
proc print data=final;
run;
The following output displays the results:
Creating a View with a Dummy BY Variable
  The SAS System
Obs        name       age
 1         ALBERT      10
 2         anne        35
 3         BRIAN       45
 4         bridget     23
 5         janet        5
 6         JUAN        90

See Also

Procedures
SORT Procedure in Base SAS Procedures Guide