The DFSORT OPTION SKIPREC=n tells the sort step to skip the first n records of the input. Those records are never read into the sort or merge logic and never appear in the output. SKIPREC is useful when your input has a fixed number of leading records you do not want to process—for example a one-line header, multiple header lines, or a few bad or control records at the start of the file. This page explains how SKIPREC works, how it interacts with other control statements, and when to use it instead of INCLUDE or OMIT.
When you specify OPTION SKIPREC=n, DFSORT behaves as if the first n records of the input do not exist. It does not read them into memory for sorting, merging, or reformatting; it does not pass them to INCLUDE or OMIT; and it does not write them to SORTOUT or any OUTFIL. So the effective input to your step is "everything after the first n records." The value n must be a non-negative integer. Common values are 1 (skip one header line) or a small number (e.g. 3 or 5) when you have multiple header or control lines at the top of the file.
Code SKIPREC as part of the OPTION statement in SYSIN. You can combine it with other options, separated by commas. The OPTION statement usually appears before the SORT FIELDS= or MERGE FIELDS= statement (or before OPTION COPY if you are not sorting). Example:
12OPTION SKIPREC=1 SORT FIELDS=(1,20,CH,A)
To skip the first five records and also use a stable sort:
12OPTION EQUALS,SKIPREC=5 SORT FIELDS=(10,4,PD,D)
If you omit SKIPREC (or use SKIPREC=0 where that is allowed), no input records are skipped; processing starts from the first record.
SKIPREC is purely positional: it skips the first n records regardless of their content. INCLUDE and OMIT are conditional: they keep or drop records based on field values, ranges, or patterns. Use SKIPREC when the records you want to skip are always the first n. Use INCLUDE or OMIT when you identify records by content (e.g. "drop all records where byte 1 is 'H'" or "keep only records where the type field is 'D'"). If your "header" can appear in different positions or you have multiple types of records to exclude by value, INCLUDE/OMIT is the right tool. If you always have exactly one header line at the top, SKIPREC=1 is simpler and avoids building a condition.
| Aspect | Behavior |
|---|---|
| What is skipped | First n records of input only |
| When applied | Before any INCLUDE/OMIT, INREC, or sort |
| Output | Skipped records do not appear in SORTOUT or OUTFIL |
| Typical use | Headers, bad leading records, fixed-position trailers |
SKIPREC is applied at the very beginning of input processing. The sequence is: (1) read input; (2) skip the first n records (SKIPREC); (3) for the remaining records, apply INCLUDE/OMIT; (4) apply INREC if present; (5) sort or merge (or copy with OPTION COPY); (6) apply SUM if present; (7) apply OUTREC/OUTFIL. So skipped records never participate in filtering, reformatting, or sorting. They are simply not seen by the rest of the step.
Because skipped records are not read into the sort/merge logic, they are typically not counted in the "records in" total that DFSORT reports in its completion messages. The input dataset still contains those records on disk; DFSORT just advances past them. So your job output might show something like "100000 records in, 100000 records out" when the file actually has 100005 records—the 5 skipped are not in the count. From a performance perspective, skipping is cheap: DFSORT still reads the skipped records from the dataset (to move the read position forward) but does no further work on them. So SKIPREC does not reduce I/O for the skipped portion; it only reduces how many records are processed by the sort/merge and downstream logic.
With MERGE, you have multiple input streams. Whether SKIPREC applies to each stream, only the first stream, or in some other way depends on your DFSORT product and version. In some implementations, SKIPREC=n causes each merge input to skip its first n records. In others, it may apply only to the first DD or be documented differently. If you use MERGE and need to skip leading records, check your product documentation and, if necessary, test with a small file to confirm behavior. For a single-input SORT, SKIPREC always applies to SORTIN.
Skip one header and sort by position 1–10 character ascending:
12OPTION SKIPREC=1 SORT FIELDS=(1,10,CH,A)
Skip three header lines and copy (no sort) with reformatting:
12OPTION COPY,SKIPREC=3 OUTREC FIELDS=(1,80)
In the second example, no SORT FIELDS= is used, so OPTION COPY is in effect. The first three records are skipped; the rest are copied with OUTREC formatting.
Imagine a stack of cards where the first few cards are instructions (e.g. "This stack has 100 cards"). You want to sort only the real data cards. SKIPREC is like saying: "Ignore the first 3 cards and sort the rest." So you take the first 3 off and put them aside, then sort everything that is left. The first 3 never get sorted and never go into the result pile.
1. What does OPTION SKIPREC=n do?
2. You have a file with one header record and 10,000 data records. You want to sort the data only. What do you use?
3. Does SKIPREC affect the record count in DFSORT messages?
4. Can you use SKIPREC with MERGE?
5. What happens if you specify SKIPREC=0?