Sorting data sets
To use DFSORT directly (JCL-invoked), write a SORT control statement to describe the control fields, and the order in which you want them sorted. The control statements you write are part of the SYSIN data set in the JCL. The SYSIN data set is typically specified as //SYSIN DD * followed by "inline" control statements (as shown in the examples in this document). However, a sequential data set, or a member of a partitioned data set, with the control statements as records can also be used for the SYSIN data set.
You can use SORT with all of the other DFSORT control statements.
A SORT statement that sorts the bookstore records by the course
department field (as shown in Table 2) looks
like this: 
Make sure that the statement is coded between columns 2 and 71.
Here are the steps for writing this SORT statement:
| Step | Action |
|---|---|
| 1 | Leave at least one blank, and type SORT |
| 2 | Leave at least one blank and type FIELDS= |
| 3 | Type, in parenthesis and separated
by commas:
|
Remember that although Table 2 shows only certain fields, the displayed fields are not the only ones in the output data set. Your output data set will more closely resemble the fold-out of the sample bookstore data set.
| Book Title | Course Department |
|---|---|
1 75
|
110 114
|
LIVING WELL ON A SMALL BUDGET
PICK'S POCKET DICTIONARY INTRODUCTION TO BIOLOGY SUPPLYING THE DEMAND STRATEGIC MARKETING COMPUTER LANGUAGES VIDEO GAME DESIGN COMPUTERS: AN INTRODUCTION NUMBERING SYSTEMS SYSTEM PROGRAMMING INKLINGS: AN ANTHOLOGY OF YOUNG POETS EDITING SOFTWARE MANUALS MODERN ANTHOLOGY OF WOMEN POETS THE COMPLETE PROOFREADER SHORT STORIES AND TALL TALES THE INDUSTRIAL REVOLUTION EIGHTEENTH CENTURY EUROPE CRISES OF THE MIDDLE AGES INTRODUCTION TO PSYCHOLOGY ADVANCED TOPICS IN PSYCHOANALYSIS |
BIOL BUSIN BUSIN COMP COMP COMP COMP COMP ENGL ENGL ENGL ENGL ENGL HIST HIST HIST PSYCH PSYCH |
To sort the records in descending order, specify D instead
of A. For example, to sort the prices for each book in descending
order, type:
The sort order is bytes 170 through 173 as binary data in descending sequence. Table 3 shows the results of the sort in descending order.
| Book Title | Price |
|---|---|
1 75
|
170 173
|
LIVING WELL ON A SMALL BUDGET
SYSTEM PROGRAMMING COMPUTER LANGUAGES ADVANCED TOPICS IN PSYCHOANALYSIS STRATEGIC MARKETING INTRODUCTION TO BIOLOGY INTRODUCTION TO PSYCHOLOGY VIDEO GAME DESIGN SUPPLYING THE DEMAND COMPUTERS: AN INTRODUCTION EIGHTEENTH CENTURY EUROPE SHORT STORIES AND TALL TALES EDITING SOFTWARE MANUALS CRISES OF THE MIDDLE AGES THE INDUSTRIAL REVOLUTION THE COMPLETE PROOFREADER INKLINGS: AN ANTHOLOGY OF YOUNG POETS MODERN ANTHOLOGY OF WOMEN POETS NUMBERING SYSTEMS PICK'S POCKET DICTIONARY |
9900
3195 2600 2600 2350 2350 2200 2199 1925 1899 1790 1520 1450 1200 795 625 595 450 360 295 |