Creating different subsets of a sorted data set

If you want to create subsets of records from the same input data set, you can use OUTFIL statements with a SORT or COPY operator. The OUTFIL statements specify the ddnames of the output data sets, so the TO operand is not needed. All of the features of OUTFIL are available through the SORT and COPY operators.

A SORT operator that creates separate disk and tape data sets for the branch offices in California, and those in Colorado, sorted by city looks like this: A SORT operator that creates separate disk and tape data sets for the branch offices in California, and those in Colorado, sorted by city

Here are the steps for writing this SORT operator:

Table 1. Steps to Create the SORT Operator
Step Action
1 Write a comment statement (optional):
* Separate output for California and Colorado branches
2 Type SORT after the comment statement
3 Leave at least one blank and type FROM(ALL)

ALL specifies the ddname for the input data set you want to sort. You can use the same ddname that you used for A123456.SORT.BRANCH in the STATS operator.

4 Leave at least one blank and type USING(CACO)

The CACOCNTL data set contains the SORT and OUTFIL statements.

To write the JCL statements that go with the SORT operator follow these steps:

Table 2. Steps to Create JCL Statements for the SORT Operator
Step Action
1 Write a DD statement for the DFSORT control statement data set and place it at the end of the job:
//CACOCNTL DD *
2 Write the SORT control statement to sort the input data set by city, the OUTFIL statement to select only the California branches, and the OUTFIL statement to select only the Colorado branches, and place them after the CACOCNTL statement:
  SORT FIELDS=(1,15,CH,A)
  OUTFIL FNAMES=(CADASD,CATAPE),INCLUDE=(16,2,CH,EQ,C'CA')
  OUTFIL FNAMES=(CODASD,COTAPE),INCLUDE=(16,2,CH,EQ,C'CO')
3 Write DD statements for the disk and tape output data sets and place them at the end of the job:
//CADASD DD  DSN=&&CA,DISP=(,PASS),SPACE=(CYL,(2,2)),UNIT=3390
//CATAPE DD DSN=CA.BRANCH,UNIT=3480,VOL=SER=111111,
//  DISP=(NEW,KEEP),LABEL=(,SL)
//CODASD DD  DSN=&& CO,DISP=(,PASS),SPACE=(CYL,(2,2)),UNIT=3390
//COTAPE DD DSN=CO.BRANCH,UNIT=3480,VOL=SER=222222,
//  DISP=(NEW,KEEP),LABEL=(,SL)

When complete, the TOOLIN statements and DD statements for this SORT operator look like this:

* Separate output for California and Colorado branches
SORT FROM(ALL) USING(CACO)
/*
//CACOCNTL DD *
  SORT FIELDS=(1,15,CH,A)
  OUTFIL FNAMES=(CADASD,CATAPE),INCLUDE=(16,2,CH,EQ,C'CA')
  OUTFIL FNAMES=(CODASD,COTAPE),INCLUDE=(16,2,CH,EQ,C'CO')
/*
//CADASD DD  DSN=&&CA,DISP=(,PASS),SPACE=(CYL,(2,2)),UNIT=3390
//CATAPE DD DSN=CA.BRANCH,UNIT=3480,VOL=SER=111111,
//  DISP=(NEW,KEEP),LABEL=(,SL)
//CODASD DD  DSN=&&CO,DISP=(,PASS),SPACE=(CYL,(2,2)),UNIT=3390
//COTAPE DD DSN=CO.BRANCH,UNIT=3480,VOL=SER=222222,
//  DISP=(NEW,KEEP),LABEL=(,SL)

Table 3 shows the records as they would appear in the CADASD data set (&&CA) and the CATAPE data set (CA.BRANCH) as a result of using the first OUTFIL statement.

Table 3. Records for California Sorted by City
City State Employees Revenue Profit
1 15 16 17 18 21 22 27 28 33
Los Angeles CA 32 22530 -4278
Morgan Hill CA 15 18200 3271
Sacramento CA 29 42726 8276
San Diego CA 22 32940 8275
San Francisco CA 35 42820 6832
San Jose CA 21 27225 8264
Sunnyvale CA 18 16152 -978
         

Table 4 shows the records as they would appear in the CODASD data set (&&CO) and the COTAPE data set (CO.BRANCH) as a result of using the second OUTFIL statement.

Table 4. Records for Colorado Sorted by City
City State Employees Revenue Profit
1 15 16 17 18 21 22 27 28 33
Aspen CO 20 25800 5200
Boulder CO 32 33866 7351
Denver CO 33 31876 6288
Fort Collins CO 22 12300 -2863
Vail CO 19 23202 5027

Figure 3 shows the complete TOOLMSG output.

So far
So far in this tutorial, you have learned how to print statistics for numeric fields using ICETOOL's STATS operator, and how to sort an input data set and create multiple output data sets using ICETOOL's SORT operator. Next, you will learn about ICETOOL's COPY operator.