z/OS DFSORT: Getting Started
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Sorting data sets

z/OS DFSORT: Getting Started
SC23-6880-00

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: A SORT statement that sorts the bookstore records by the course department field

Make sure that the statement is coded between columns 2 and 71.

Here are the steps for writing this SORT statement:

Table 1. Steps to Create the SORT Statement to Sort by Department
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:
  1. Where the course department field begins, relative to the beginning of the record in the bookstore data set (the first position is byte 1). The course department field begins at byte 110.
  2. The length of the department field in bytes. The department field is 5 bytes long.
  3. A format identifier for the data format. The department field contains character data, which you specify as CH. ( Table 2 shows the codes for the most commonly used data formats.)
  4. The letter A, for ascending order.

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.

Table 2. Sample Bookstore Data Set Sorted by Course Department in Ascending Order
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:Sorting the prices for each book in descending order

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.

Table 3. Sample Bookstore Data Set Sorted by Price 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

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014