When working with data sets
containing numeric fields, you may
want statistical information about one or more of those fields. You
can use the STATS operator to find the minimum, maximum, average,
and total values of up to 10 specific numeric fields.
A STATS
operator that prints statistics for the employees, profit,
and revenue fields of the branch office data set looks like this:
Here are the steps for writing this STATS
operator.
Table 1. Steps
to Create
the STATS OperatorStep |
Action |
---|
1 |
Type STATS after the comment
statement (you can leave one or more blanks before STATS if you like). |
2 |
Leave at least one blank and type FROM(ALL) FROM
specifies the ddname (that is, the name of the DD statement) for the
input data set from which you want to print statistics. In this case
ALL is the ddname chosen, but you can use any valid 1-8 character
ddname you like.
|
3 |
Leave at least one blank and type ON ON
defines a field for which you want to print statistics.
|
4 |
Type in parentheses, and separated
by commas: - Where the employees field begins relative to the
beginning of
the input record (the first position is byte 1). The employees field
begins at byte 18.
- The length of the employees field
in bytes. The employees field
is 4 bytes long.
- A code for the data format. The employees
field contains zoned
decimal data, which you specify as ZD.
|
5 |
Leave at least one blank and type ON ON
defines another field for which you want to print statistics. You
can print statistics for up to 10 fields with one STATS statement.
Specify the ON fields in the same order in which you want their statistics
to be printed.
|
6 |
Type in parentheses, and separated
by commas the location (28), length (6), and format
(PD for packed decimal) of the profit field. |
7 |
Leave at least one blank and type ON.
Type in parentheses and separated by commas, the location (22),
length (6), and format (PD) of the revenue field. Make
sure that the statement is coded between columns 1 and 72.
|
You must also write a DD statement
for the A123456.SORT.BRANCH
data set using the ddname ALL and place it at the end of the job:
//ALL DD DSN=A123456.SORT.BRANCH,DISP=SHR
When complete the TOOLIN statements and ALL statement look like
this:
//TOOLIN DD *
* Statistics from all branches
STATS FROM(ALL) ON(18,4,ZD) ON(28,6,PD) ON(22,6,PD)
/*
//ALL DD DSN=A123456.SORT.BRANCH,DISP=SHR
When this
STATS operation is run, the results are placed in the
TOOLMSG data set. If you ran the ICETOOL job you created so far,
the TOOLMSG output would look like this:
ICE600I 0 DFSORT ICETOOL UTILITY RUN STARTED
ICE650I 0 VISIT http://www.ibm.com/storage/dfsort FOR ICETOOL PAPERS, EXAMPLES AND MORE
ICE632I 0 SOURCE FOR ICETOOL STATEMENTS: TOOLIN
ICE630I 0 MODE IN EFFECT: STOP
* Statistics from all branches
STATS FROM(ALL) ON(18,4,ZD) ON(28,6,PD) ON(22,6,PD)
ICE627I 0 DFSORT CALL 0001 FOR COPY FROM ALL TO E35 EXIT COMPLETED
ICE628I 0 RECORD COUNT: 000000000000012
ICE607I 0 STATISTICS FOR (18,4,ZD) :
ICE608I 0 MINIMUM: +000000000000015, MAXIMUM: +000000000000035
ICE609I 0 AVERAGE: +000000000000024, TOTAL : +000000000000298
ICE607I 0 STATISTICS FOR (28,6,PD) :
ICE608I 0 MINIMUM: -000000000004278, MAXIMUM: +000000000008276
ICE609I 0 AVERAGE: +000000000004222, TOTAL : +000000000050665
ICE607I 0 STATISTICS FOR (22,6,PD) :
ICE608I 0 MINIMUM: +000000000012300, MAXIMUM: +000000000042820
ICE609I 0 AVERAGE: +000000000027469, TOTAL : +000000000329637
ICE602I 0 OPERATION RETURN CODE: 00
ICE601I 0 DFSORT ICETOOL UTILITY RUN ENDED - RETURN CODE: 00
Looking at the output, you will notice that:
- Message
ICE628I gives the count of records processed.
- Messages ICE607I,
ICE608I, and ICE609I give the numerical statistics
for each ON field specified in the order in which they were specified.
- A return code for each operator is given in message ICE602I and
the highest operator return code is given in message ICE601I.