Not equal asks the opposite of equality: are these two values different? The symbolic operator <>—angle brackets with a slash conceptually between them—appears in IF conditions when you want records that fail to match a code, amounts that changed since last cycle, or departments excluded from a corporate rollup. Keyword NE performs the same test and appears frequently in legacy manuals where symbolic punctuation was discouraged on 80-column cards. Exception processing lives on not equal: IF ERROR-FLAG <> 0 PRINT ERRORS-RPT surfaces only problem rows. Beginners underuse <> because positive filters—IF DEPT = 911—read more naturally, but exclusion logic—IF DEPT <> 999— often matches business questions better. This page covers syntax, NE equivalence, numeric and alphabetic inequality, combination with AND OR NOT, contrast with equal and THRU, duplicate-change detection, and testing strategies for production-grade filters.
Not equal appears between operands in conditional expressions: IF STATUS <> T, IF GROSS <> 0, IF NEW-KEY <> OLD-KEY. True when values differ; false when they compare equal under type rules. Use in IF ELSE-IF DO WHILE and nested conditions. Does not modify operands.
12345678JOB INPUT PAYROLL IF ERROR-CODE <> 0 PRINT EXCEPTION-RPT END-IF IF NEW-GROSS <> PRIOR-GROSS PRINT CHANGE-RPT END-IF
| Form | Example | Notes |
|---|---|---|
| Symbolic <> | IF FLAG <> Y | Compact; familiar from SQL-like syntax |
| Keyword NE | IF FLAG NE Y | Matches EQ GE LE keyword family |
| NOT ... = | IF NOT FLAG = Y | Logical negation of equality—mind precedence |
IF STATUS NE X and IF STATUS <> X are equivalent in standard grammar. Choose one style per program section for maintainability. Code reviewers scanning for NE find all relational tests quickly when you avoid mixing six symbolic and six keyword forms randomly.
IF BALANCE <> 0 includes positive and negative non-zero balances—only exact zero fails the inequality. IF TAX <> FED-TAX flags rows where two tax fields diverge. Packed decimal compares by value: 10.00 <> 10.01 is true at P 2 scale. Watch implied decimal alignment when comparing P 2 to N 5—values that display the same may still compare unequal internally if conversion differs. Zero versus LOW-VALUES: uninitialized packed fields may not equal business zero—validate FILE data before trusting <> 0 as valid record test.
IF REGION <> 99 excludes region ninety-nine when REGION is N 2 or A 2 depending on definition. IF NAME <> PRIOR-NAME detects name changes between history and current file merge. Trailing spaces cause false inequality: ARNOLD-space versus ARNOLD-space on equal-length fields compares equal; ARNOLD-space versus ARNOLD literal may compare unequal if literal padding differs. Trim or normalize before <> when business rules ignore blanks.
Inclusion: IF DEPT = 911 keeps one department. Exclusion: IF DEPT <> 999 keeps every department except 999. When valid codes are few, equality lists are shorter. When one bad code must drop, not equal is clearer than long OR chains of allowed equals. Multiple exclusions: IF CODE <> X AND CODE <> Y AND CODE <> Z—or refactor to positive allow-list with equality and OR when codes are enumerable.
Prior-cycle compare files drive reconciliation jobs. IF CURR-AMT <> PRIOR-AMT PRINT CHANGE-RPT highlights adjustments. Sort both files by key, read in parallel or merge pattern, compare field by field with <>. Pair with = for no-change skip: IF CURR-AMT = PRIOR-AMT skip detail PRINT when only exceptions matter—reduces spool volume.
123456789JOB INPUT MASTER IF RECORD-STATUS <> 'A' PRINT INACTIVE-RPT END-IF IF ZIP-CODE <> PRIOR-ZIP MOVE ZIP-CODE TO PRIOR-ZIP PRINT ADDRESS-CHANGE-RPT END-IF
IF STATUS <> X AND STATUS <> Y requires both inequalities—status differs from X and from Y. IF TYPE <> A OR TYPE <> B is almost always true for any TYPE value—a common logic bug; beginner meant AND or a single not-equal against a set. IF NOT DEPT = 911 equals IF DEPT <> 911 when NOT applies to the equality subexpression. Parentheses prevent surprises: IF (A <> B) AND (C <> D).
Inequality <> only tests difference—not ordering. IF AGE <> 18 includes ages below and above eighteen. IF AGE GT 18 excludes minors only. Pick operator matching business rule wording. Auditors asking for everyone not exactly sixty-five need <> 65 or NOT = 65, not GT 65 alone.
Single <> compare per record is inexpensive. Long chains of AND <> on many literals cost more in maintenance than lookup table or range design. Consider E-Z Table or site validation patterns when excluding dozens of codes—architecture choice beyond operator mechanics but affects nightly batch CPU when IF trees grow deep.
Not equal means not the same. If everyone wearing a red hat goes to circle A, not equal red sends everyone else—blue hats, green hats, no hats—to circle B. The <> sign is a way of saying these two things do not match. It is the opposite of asking are they the same? Spelling NE means the same thing as <>—like saying isn't instead of is not. Be careful when you say not red and not blue—you might accidentally include almost everyone unless you really mean both rules at once.
1. IF STATUS <> X means:
2. NE is:
3. IF DEPT <> 999 filters:
4. NOT STATUS = X compared to STATUS <> X:
5. Alphabetic <> compares: