ICETOOL Operators Deep Dive

ICETOOL performs work by running one or more operators. Each operator is a single task: copy data, sort data, merge files, count records, select a subset, compute statistics, and so on. This page goes deeper into the main ICETOOL operators: what each does, when to use it, and how it fits with the USING (control statement) dataset. We cover COPY, SORT, MERGE, COUNT, SELECT, DISPLAY, STATS, SUBSET, UNIQUE, DATASORT, and MODE.

Control Statements (Core Syntax)
Progress0 of 0 lessons

COPY Operator

COPY copies records from the input DD (FROM) to the output DD(s) (TO). Without USING, it is a straight copy. With USING(prefix), the prefixCNTL dataset can contain INCLUDE, OMIT, INREC, OUTREC, OUTFIL, etc., so you can filter and reformat while copying. COPY does not sort; order is preserved (or as defined by OPTION COPY in the control statements).

text
1
2
3
4
5
6
COPY FROM(INDD) TO(OUTDD) USING(CTL1) /* //CTL1CNTL DD * INCLUDE COND=(60,2,CH,EQ,C'IN') OUTREC FIELDS=(1,80) /*

SORT Operator

SORT sorts the input and writes to the output. You must supply USING(prefix) with a dataset that contains SORT FIELDS=. Optionally the same dataset can have INCLUDE, OMIT, INREC, OUTREC, OUTFIL, SUM. SORT allows multiple input files (e.g. FROM(IN1,IN2)) in some implementations; control statements then typically use MERGE FIELDS= or SORT FIELDS=.

MERGE Operator

MERGE merges two or more sorted inputs into one or more outputs. You need multiple FROM DDs (e.g. FROM(IN1,IN2)) and control statements with MERGE FIELDS= and often OUTFIL to split or format the merged stream.

COUNT Operator

COUNT counts records. FROM(indd) is required. If you use USING(ctl), the ctlCNTL dataset can have INCLUDE so only records that meet the condition are counted. The count is written to TOOLMSG (or a count dataset). No data records are written to an output file.

SELECT Operator

SELECT selects records by key. Typical syntax includes ON(position,length,format) and FIRST(n) or LAST(n)—e.g. first 2 records per department. The selected records are written to the TO(...) DD. So you get a subset of the input (e.g. top N per group).

DISPLAY and STATS Operators

DISPLAY computes aggregates (min, max, total, average, count) for specified numeric fields and writes the result to a list dataset (LIST(listdd)). STATS displays statistics (min, max, average, total) for specified fields, often to the message output. Both operate on numeric data; exact syntax (ON, field list, format) is product-dependent.

SUBSET Operator

SUBSET copies a subset of records by including or removing header and/or trailer records. You specify how many lines are header (HEADER(n)) and how many are trailer (TRAILER(n)), and whether to REMOVE or OUTPUT (keep) them. So you can strip header/trailer or keep only data records.

UNIQUE Operator

UNIQUE counts the number of unique values in a specified field (ON(position,length,format)) and writes that count to messages or a list file. It does not produce an output file of data records; it produces a single count.

DATASORT Operator

DATASORT is for files that have a fixed number of header records at the top and trailer records at the bottom. You specify HEADER(n) and TRAILER(n). ICETOOL sorts only the records in between and writes header + sorted data + trailer to the output. So the structure of the file (header/trailer) is preserved.

MODE Operator

MODE controls what happens when an operator returns a non-zero return code. STOP (default in many setups) stops processing; no further operators run. CONTINUE continues with the next operator. SCAN may continue but can affect how errors are reported. Use MODE when you want one failure not to stop the rest of the step.

Operator summary
OperatorPurpose
COPYCopy input to output; optional INCLUDE/OUTREC via USING
SORTSort input and write to output; needs SORT FIELDS= in USING
MERGEMerge multiple sorted inputs
COUNTCount records (optionally with INCLUDE); result to messages or count DD
SELECTSelect records by key (e.g. FIRST n per group)
DISPLAYAggregates (min/max/total/avg) to list dataset
STATSStatistics for numeric fields to messages
SUBSETInclude/remove header and trailer lines
UNIQUECount unique values in a field
DATASORTSort only data between header and trailer
MODEError handling: STOP, CONTINUE, SCAN

Explain It Like I'm Five

Each operator is like a different job for the same pile of papers. COPY is “copy these to that box.” SORT is “put them in order by name and then copy.” COUNT is “count how many are blue.” SELECT is “give me only the first two from each group.” DISPLAY is “tell me the smallest, biggest, and total number.” MODE is “if one job fails, do we stop or keep doing the next job?” So you pick the operator that matches what you want: copy, sort, count, select, or summarize.

Exercises

  1. Write TOOLIN and one CNTL for COPY with INCLUDE so only records with bytes 10–11 equal 'AB' are copied.
  2. When would you use DATASORT instead of SORT? Give an example file structure.
  3. What is the difference between COUNT and UNIQUE?
  4. If you want to run COUNT then SORT in one step and have the step continue even if COUNT fails, where do you put MODE CONTINUE?

Quiz

Test Your Knowledge

1. Which ICETOOL operator would you use to copy records from one file to another with optional INCLUDE/OUTREC?

  • SORT only
  • COPY—optionally with USING(xxxx) for DFSORT control statements
  • COUNT
  • MERGE

2. What does the SELECT operator do?

  • Sorts only
  • Selects records by key—e.g. ON(field) FIRST(n) keeps the first n records per key value
  • Merges two files
  • Counts unique values only

3. When would you use DATASORT instead of SORT?

  • Always use DATASORT
  • When the file has header and trailer records that must stay in place—DATASORT sorts only the data records between them
  • Only for variable length
  • DATASORT is the same as COPY

4. What does the MODE operator control?

  • Sort order only
  • Error handling—STOP, CONTINUE, or SCAN after an operator returns a non-zero return code
  • Input format only
  • Output file count

5. Which operator writes aggregate information (min, max, total, average) to a list dataset?

  • COUNT
  • DISPLAY—writes numerical aggregates to a list file
  • COPY
  • SELECT