9.2 – Full Description
If you are sorting on the entire record using character data, you
do not need to specify your key field. Otherwise, specify a /KEY
qualifier for each of the keys, in the order of their priority.
You can sort on as many as 255 key fields.
There are three ways to use the /KEY qualifier:
o To identify the key field name.
o To identify the key field name and to specify sorting order.
In this case, enclose the field name and the order option in
parentheses.
o As a conditional qualifier, to change the order of records
in the output file. First, specify a condition name in a
/CONDITION qualifier, and set up a test for what meets
that condition. Then, specify the relative order in a /KEY
qualifier of the form:
/KEY=(IF condition-name THEN value ELSE value)
You can use any values to specify the relative order of the
records.
9.3 – Examples
1./FIELD=(NAME=SALARY,POSITION:10,DIGITS:8,DECIMAL)
/KEY=(SALARY,DESCENDING)
This /KEY qualifier specifies that the key field is SALARY and
that the sorting order is descending.
2./FIELD=(NAME=ZIP,POSITION:20,SIZE:6)
/CONDITION=(NAME=LOCATION,
TEST=(ZIP EQ "01863"))
/KEY=(IF LOCATION THEN 1
ELSE 2)
In this example, all the records with the zip code 01863 are
to appear at the beginning of the sorted output file. The
conditional test LOCATION (defined in a /CONDITION qualifier)
is on the ZIP field (named in a /FIELD clause). The values of
1 and 2 in this /KEY clause signify a relative order for those
records that satisfy the condition and those that do not.
10 /OMIT
Specifies that records are to be omitted from the output file
based on a condition defined with a /CONDITION qualifier.
Format
/OMIT=(CONDITION=condition-name)
10.1 – Qualifier Value
CONDITION=condition-name
Refers to the condition-name previously specified in a /CONDITION
qualifier.
10.2 – Full Description
You can specify that records are to be omitted from the output
file by using the /OMIT qualifier. First, you must define a
condition with the /CONDITION qualifier. Specify your record
selection with an /OMIT qualifier requesting the records
satisfying that condition be selected for omission from your
sort. By default, Sort/Merge includes all the other input records
in the output file.
You can specify multiple /OMIT and /INCLUDE qualifiers in your
specification file. The order you specify them determines the
order the input records are tested for omission. All the records
that have not already been included or omitted after the last
/OMIT qualifier are included. You can unconditionally omit any
records not previously omitted or included by specifying the
/OMIT qualifier only.
10.3 – Example
/FIELD=(NAME=ZIP,POSITION:20,SIZE:6)
/CONDITION=(NAME=LOCATION,
TEST=(ZIP EQ "01863"))
/OMIT=(CONDITION=LOCATION)
These /CONDITION and /OMIT qualifiers specify that records with
the zip code 01863 are to be omitted from your output file.
11 /PAD
Allows you to specify a pad character to use when reformatting
records or when comparing strings of unequal length.
Format
/PAD=single-character
11.1 – Qualifier Value
single-character
Specifies the character that the Sort utiltiy will use to pad a
string. Characters, decimal, octal, or hexadecimal digits can be
used. The pad character should be specified as follows:
o Use quotation marks for a character. For example, " # " would
specify the number sign.
o Use decimal radix for decimal digits. For example, %D35 would
specify the decimal number 35.
o Use octal radix for octal digits. For example, %O043 would
specify the octal number 043.
o Use hexadecimal radix for hexadecimal digits. For example,
%X23 would specify the hexadecimal number 23.
11.2 – Full Description
Use the /PAD qualifier to specify a pad character when comparing
strings of unequal length or when reformatting records. By
default, Sort uses the null character for padding, ensuring
conformity with the previous versions. Double characters that
can be defined as single characters ("ch" > "c") cannot be used
as pad characters.
11.3 – Example
/PAD="."
This example of a /PAD qualifier specifies that records will be
padded with periods.
12 /PROCESS
Defines the processing method (record, tag, address, or index)
for the sorting operation. Use only with the SORT command.
Format
/PROCESS=type
12.1 – Qualifier Values
RECORD
Specifies the record sort. This sort process is the default.
TAG
Specifies the tag sort.
ADDRESS
Specifies the address sort.
INDEX
Specifies the index sort.
12.2 – Full Description
By default, Sort uses a record sorting process. You can also
specify a tag, address, or index sorting process. If you intend
to reformat the output records, you cannot use address or index
sort. For a comparison of the four processes, see the description
of /PROCESS in the Command Qualifiers Section. Use the /PROCESS
qualifier with the SORT command only.
12.3 – Example
/PROCESS=tag
This example of the /PROCESS qualifier specifies that Sort use
a tag sorting process.
13 /STABLE
Specifies that records with equal keys are directed to the
output file in their input file order. The default condition
is /NOSTABLE.
Formats
/STABLE
/NOSTABLE
13.1 – Full Description
By default, when records are sorted with identical keys, the
order of those records in the output file may not be the same as
they appeared in the input file. Specifying the /STABLE qualifier
in a specification file arranges records with equal keys in the
output file in the order of the input files as specified in the
command line. If you use this qualifier when sorting multiple
input files, on output, records with equal keys in the first file
will precede those from the second file and so on.
13.2 – Example
/STABLE
This example of the /STABLE qualifier ensures that records with
equal keys will have the same order in the input and output
files.
14 /WORK_FILES
Reassigns work files to different disk-structured devices to
improve performance. Use only with the SORT command.
Format
/WORK_FILES=(device[,...])
14.1 – Qualifier Value
device
Specifies a logical name for the work file. Unlike the DCL
qualifier /WORK_FILES=n, the specification file qualifier /WORK_
FILES=(device[,...]) specifies work file assignments, not the
number of work files.
14.2 – Full Description
You can improve the performance of Sort by placing work files
on different disk-structured devices. Using the /WORK_FILES
qualifier in a specification file to reassign work files makes
it unnecessary to make logical assignments prior to invoking Sort
at the command or program level.
14.3 – Example
/WORK_FILES=("WRKD$:")
This example of a /WORK_FILES qualifier assigns one of Sort's
work files to the device WRKD$: because that device has the
most space available.