Printing how many times fields occur

You can use ICETOOL's OCCUR operator to print a simple or tailored report showing how many times different ON field values occur, sorted by those ON field values. Values that occur only once are called "non-duplicate" values. Values that occur more than once are called "duplicate" values.

You can list all of the values in the data set, or list different combinations of duplicate and non-duplicate values, using the following operands:
Setting up an OCCUR report is similar to setting up a DISPLAY report. Specify ON fields for OCCUR in the same order you want their values to be printed in the list data set. OCCUR also has two special ON fields you can use:

You can use up to 10 ON fields; all of the ON field values, except ON(VALCNT) and ON(VLEN), are used for sorting and counting occurrences. For example, if you use ON(1,4,CH), 'ABCD+01' and 'ABCD-01' are sorted in that order (by 1,4,CH) and counted as two occurrences of 'ABCD'. However, if you use ON(1,4,CH) and ON(5,3,FS), 'ABCD-01' is sorted before 'ABCD+01' (by 1,4,CH,A and 5,3,FS,A) and counted as one occurrence of 'ABCD-01' and one occurrence of 'ABCD+01'.

You can use the following for an OCCUR report in the same way you use them for a DISPLAY report:

Refer to z/OS DFSORT Application Programming Guide for complete details on these and other operands you can use with OCCUR.

For this example, we will use the sample bookstore data set as input. To print a report showing the number of different books in use from each publisher, write the following OCCUR statement:

Printing a report showing the number of different books in use from each publisher

BKIN is the ddname for the sample bookstore data set. PUBCT is the ddname for the list data set in which you want the report to be printed. BLANK specifies the field format to be used.

TITLE indicates the title string to appear in the title line. DATE indicates the format in which the date is to appear in the title line (dd.mm.yy where dd is the two-digit day, mm is the two- digit month and yy is the last two digits of the year).

The HEADER strings correspond to the ON fields. ON(VALCNT,N05) is a special ON field used with OCCUR to print the count of occurrences. N05 is a formatting item used to set the number of digits for the count to 5, overriding the default of 15 digits for VALCNT.

Write DD statements for the A123456.SORT.SAMPIN and PUBCT data sets and place them at the end of the job:

//BKIN DD DSN=A123456.SORT.SAMPIN,DISP=SHR
//PUBCT DD SYSOUT=A

When this OCCUR operator is run, the PUBCT data set looks like this:

Books from Publishers        21.10.03

Publisher   Books Used
---------   ----------
COR                  7
FERN                 4
VALD                 5
WETH                 4

The name of each publisher is printed along with the number of times that publisher appeared in the sample bookstore data set, which is equivalent to the number of different books from that publisher.

So far
You have now learned how use ICETOOL's OCCUR operator to print a simple or tailored report showing how many times different field values occur. Next, you will learn how to use ICETOOL's SELECT operator.