SUM Function

Purpose

Returns the sum of all the elements in an array.

Syntax

SUM(x)

Parameters

x is an array expression.

Description

The SUM function returns the sum of all the elements in the array.

If the elements of the array are strings, they are converted to fixed-point values. If they are neither fixed-point values nor strings, they are converted to floating-point values. In the latter case, the result is a floating-point value; otherwise, it is a fixed-point value.

Examples

DECLARE (A(4), I) FIXED BIN (15);

DO I = 1 to 4;
   A(I) = 4;
END

I = SUM(A);     /* returns 16 */

Restrictions

None.