MainframeMaster

OMIT Statement

The OMIT control statement filters input records by dropping those that satisfy the condition you specify; all other records are kept and passed to the sort or merge phase. You define the condition with OMIT COND=, using the same syntax as INCLUDE COND= (field position, length, format, operator, value). OMIT is the opposite of INCLUDE: INCLUDE keeps matches and drops the rest; OMIT drops matches and keeps the rest. This page covers OMIT COND= syntax, when to use OMIT instead of INCLUDE, and how both are applied during the input phase.

Control Statements
Progress0 of 0 lessons

What OMIT Does

OMIT is a filter that excludes records. For each input record, DFSORT evaluates the condition in COND=. If the condition is true, the record is dropped—it is not passed to the sort or merge and will not appear in the output. If the condition is false, the record is kept. So OMIT means "drop records that match." It is applied during the input phase, same as INCLUDE. Use OMIT when you want to remove a minority of records (e.g. header/trailer lines, invalid codes, test data) and keep everything else. Use INCLUDE when you want to keep a minority (e.g. only records for one region) and drop everything else.

OMIT COND= Syntax

The syntax is the same as INCLUDE COND=:

text
1
OMIT COND=(start,length,format,operator,value)

start and length define the field to test. format (CH, PD, ZD, BI, etc.) must match the data. operator is EQ, NE, GT, GE, LT, or LE. value is the constant (e.g. C\'X\' for character, or a number for numeric). Records for which (field operator value) is true are omitted (dropped). Records for which it is false are kept.

OMIT vs INCLUDE: Same Condition, Opposite Effect

For the same condition, INCLUDE and OMIT do the opposite:

  • INCLUDE COND=(1,1,CH,EQ,C\'H\') — Keeps only records where byte 1 is H. Drops all others.
  • OMIT COND=(1,1,CH,EQ,C\'H\') — Drops records where byte 1 is H. Keeps all others.

So if 90% of your records have something other than H in position 1, INCLUDE would keep 10% and OMIT would keep 90%. Choose the one that matches how you think: "keep only these" (INCLUDE) or "drop only these" (OMIT).

Common Uses of OMIT

  • Skip header/trailer records — e.g. OMIT COND=(1,1,CH,EQ,C\'*\') to drop records that start with an asterisk (often used for comments or headers).
  • Exclude invalid or sentinel values — e.g. OMIT COND=(50,4,PD,EQ,0) to drop records where a numeric field is zero.
  • Remove test or dummy data — e.g. OMIT COND=(5,2,CH,EQ,C\'TT\') to drop records with a test code in positions 5–6.
  • Exclude a specific code — e.g. OMIT COND=(10,1,CH,EQ,C\'D\') to drop all records with D (e.g. deleted) in position 10.

Examples

text
1
OMIT COND=(1,1,CH,EQ,C'*')

Drops records where the first byte is an asterisk. Keeps all other records. Useful when the first character marks comment or header lines.

text
1
OMIT COND=(80,1,CH,EQ,C' ')

Drops records where byte 80 is a space. Keeps records where byte 80 is not a space. (You might use this to drop blank or trailer lines if your convention puts a space in 80 for those.)

text
1
OMIT COND=(20,4,PD,EQ,0)

Drops records where the 4-byte packed-decimal field at positions 20–23 equals zero. Keeps all records with a non-zero value there.

Using Both INCLUDE and OMIT

You can code both. A record is kept only if it passes INCLUDE (if you have one) and does not match OMIT (if you have one). So first the INCLUDE filter is applied—if the record does not match INCLUDE, it is dropped. Then, of the records that passed INCLUDE, any that match OMIT are dropped. The remaining records go to the sort/merge. For clarity, many jobs use only one: either "keep only these" (INCLUDE) or "drop only these" (OMIT).

Order: INREC Then INCLUDE/OMIT

If you use INREC, the record is reformatted before INCLUDE and OMIT are evaluated. So the positions in your OMIT COND= refer to the reformatted record (after INREC), not the original input. If you do not use INREC, positions refer to the original record.

Explain It Like I'm Five

OMIT is like a bouncer who throws out certain people. You tell the bouncer: "If someone has an X on their hand, don't let them in." Everyone with X gets turned away; everyone without X gets in. INCLUDE is the opposite: "Only let in people with an X." So OMIT = "keep everyone except the ones that match." INCLUDE = "keep only the ones that match."

Exercises

  1. Write an OMIT that drops all records where bytes 1–2 are '99' (e.g. end-of-file trailer).
  2. You want to keep all records except those where position 5 is 'Z'. Write the OMIT statement.
  3. What would OMIT COND=(1,10,CH,EQ,C\'HEADER \') do? When might you use it?
  4. If you use both INCLUDE COND=(1,1,CH,EQ,C\'A\') and OMIT COND=(2,1,CH,EQ,C\'X\'), which records are kept?

Quiz

Test Your Knowledge

1. What does OMIT do in DFSORT?

  • Omits the first n records
  • Drops records that satisfy the COND= condition; all others are kept
  • Omits SORTOUT
  • Omits the sort phase

2. When is OMIT applied?

  • After the sort phase
  • During the output phase
  • During the input phase, before sort/merge
  • Only with MERGE

3. OMIT COND=(1,1,CH,EQ,C'*') keeps which records?

  • Only records with * in position 1
  • All records except those with * in position 1
  • Only the first record
  • All records with * anywhere

4. What is the difference between INCLUDE and OMIT with the same condition?

  • There is no difference
  • INCLUDE keeps matches, OMIT drops matches
  • OMIT keeps matches, INCLUDE drops matches
  • Only INCLUDE can use COND=

5. Why would you use OMIT instead of INCLUDE?

  • OMIT is always faster
  • When you want to exclude a small set (e.g. drop headers); the rest are kept
  • Only for numeric fields
  • OMIT is required for MERGE