The SUBTRACT statement performs arithmetic subtraction.

SUBTRACT{number} ...FROM{ result [ROUNDED] } ... [ ONSIZEERRORstatement-1 ] [NOTONSIZEERRORstatement-2 ] [END-SUBTRACT]

SUBTRACT{number} ...FROMnumberGIVING{ result [ROUNDED] } ... [ ONSIZEERRORstatement-1 ] [NOTONSIZEERRORstatement-2 ] [END-SUBTRACT]

SUBTRACT{CORRESPONDING} group-1FROMgroup-2 [ROUNDED] {CORR} [ ONSIZEERRORstatement-1 ] [NOTONSIZEERRORstatement-2 ] [END-SUBTRACT]

SUBTRACTTABLEsrc-tableFROMdest-table [ROUNDED] [FROMINDEX src-startTOsrc-end ] [DESTINATIONINDEX dest-start ] [ ONSIZEERRORstatement-1 ] [NOTONSIZEERRORstatement-2 ] [END-SUBTRACT]

`number`is a numeric literal or elementary numeric data item.`result`is an elementary numeric data item or, in Format 2, an elementary numeric edited data item.`group-1`and`group-2`are group items containing one or more elementary numeric data items.`statement-1`and`statement-2`are imperative statements.- CORR is an abbreviation of CORRESPONDING.
`src-table`and`dest-table`are numeric data items that are table elements. The low-order subscript of these items must be omitted. For example, if`SRC-1`was an element of a one-dimensional table, you would use`SRC-1`in the statement. If`SRC-2`was an element of a two-dimensional table, and you wanted to add all the elements in row`2`, you would use`SRC-2( 2 )`.`src-start`,`src-end`and`dest-start`are numeric literals or data items. These items may not be subscripted.

- In Format 1, the numbers are added together and the result is then subtracted from each result in turn.
- In Format 2, the numbers before the word FROM are added together and the result is subtracted from the number following the word FROM. The results are then moved to each result item.
- In Format 3, elementary numeric items in
`group-1`are subtracted from the corresponding items in`group-2`. The values are then stored in`group-2`. - Additional information can be found in Arithmetic Operations, Multiple Receiving Fields, the ROUNDED Option, the SIZE ERROR Option, and the CORRESPONDING Option.
- A Format 4 SUBTRACT statement subtracts a range of
`src-table`elements from a range of`dest-table`elements. The results are stored in`dest-table`. The first element of the`src-table`range is subtracted from the first element of the`dest-table`range, the second element from the second, and so on. `src-start`indicates the first element of the source range. If omitted, it defaults to`1`.`src-end`indicates the last element of the range (inclusive). If omitted, it is set to the current upper bound of the source table. In a multidimensional table, the range of elements varies over the innermost OCCURS.`dest-start`indicates the first element of the destination range. If omitted, it defaults to`1`. Note that the last element of the destination range is`dest-start`+`src-end`- 1.- If the SIZE ERROR phrase is used, elements for which the size error condition exists are not updated, while the remaining
elements are. If any element gets a size error, then
`statement-1`executes, otherwise`statement-2`executes.

Note: SUBTRACT TABLE is usually substantially faster than the equivalent PERFORM loop. The degree of improvement depends on the
size of the range (larger ranges show better improvement). The runtime always performs table boundary checking in SUBTRACT
TABLE, even if you do not compile with
`-Za`. The boundaries are tested only at the end points (this is a fast test and there is nothing to be gained from not performing
it).