COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Example 217 STANDARD-DEVIATION Function
Code:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NUMERIC-ARRAY
05 PICTURE 9V99 VALUE 0.05.
05 PICTURE 9V99 VALUE 1.15.
05 PICTURE 9V99 VALUE 2.50.
05 PICTURE 9V99 VALUE 3.75.
05 PICTURE 9V99 VALUE 4.55.
01 NUM-ARRAY REDEFINES NUMERIC-ARRAY.
05 NUM OCCURS 5 TIMES PICTURE 9V99.
01 A PICTURE S9V99.
PROCEDURE DIVISION.
MOVE FUNCTION STANDARD-DEVIATION (NUM(ALL)) TO A.
DISPLAY A.
MOVE FUNCTION STANDARD-DEVIATION (9 2 5 3.5) TO A.
DISPLAY A.
MOVE FUNCTION STANDARD-DEVIATION (1.5 3.6 7.8 4.9) TO A.
DISPLAY A.
Output:
1.64
2.60
2.28
SUM Function
SUM is a function that returns the sum of its arguments. Its type depends on the type of its arguments,
as this table shows:
Function TypeArgument Type
IntegerInteger
NumericNumeric (some can be integer)
argument
is an integer or numeric argument.
argument can be an array; for example,
FUNCTION SUM (ARRAY1(ALL))
returns the sum of the elements of the array ARRAY1.
The returned value is
where n is the number of arguments.
SUM Function 691










