INCLUDE Numeric Tests


Numeric tests are used to evaluate and filter records based on numeric data. These tests can be applied to fields containing numeric values, such as Zoned Decimal (ZD), Packed Decimal (PD), or FS formats. Numeric tests are typically used in the INCLUDE control statements to include records that meet specific numeric conditions.

Syntax -

//SYSIN DD * 
    SORT FIELDS=COPY
    INCLUDE COND=(field1_starting_position, 
	     field1_length, field1_format,
		 relational_operator, NUM)
/*
field1_starting_positionSpecifies the starting position of field1 to be compared
field1_lengthSpecifies the length of the field1 to be compared
field1_formatSpecifies the format of the field1.
  • FS is the format to test for character numeric('0'-'9' in every byte).
  • ZD (Zoned Decimal) - Each digit is stored in a separate byte, with the sign in the last byte.
  • PD (Packed Decimal) - Two digits are stored in one byte, and the last nibble contains the sign.
relational_operatorused for condition comparison. The available operators are -
EQ 		Equal to
NE 		Not equal to
GT 		Greater than
GE 		Greater than or equal to
LT 		Less than
LE 		Less than or equal to
NUM can be used to specify a test for numeric or non-numeric.

Examples -


Scenario1 - Include records where a numeric field equals a value.

//SYSIN   DD *
  SORT FIELDS=COPY
  INCLUDE COND=(1,5,ZD,EQ,+1000)
/*

Includes records where the 5-byte zoned decimal field starting at position 1 equals 1000.

Scenario2 - Include records where a packed decimal field is not equal to a value.

//SYSIN   DD *
  SORT FIELDS=COPY
  INCLUDE COND=(15,6,PD,NE,+10000)
/*

Includes records where the 6-byte packed decimal field starting at position 15 is not equal to 10000.

Scenario3 - Include records where a binary field falls within a range.

//SYSIN   DD *
  SORT FIELDS=COPY
  INCLUDE COND=(20,4,BI,GE,+5000,AND,20,4,BI,LE,+10000)
/*

Includes records where the 4-byte binary field starting at position 20 is between 5000 and 10000.