Language Reference

CUSUM Function

CUSUM (matrix) ;

This function is supported by the IML procedure and the iml action.

The CUSUM function computes cumulative sums. The argument to this function is a numeric matrix or literal.

The CUSUM function returns a matrix of the same dimension as the argument matrix. The result contains the cumulative sums obtained by adding the nonmissing elements of the argument in row-major order.

For example, the following statements compute cumulative sums:

a = cusum({1 2 4 5});
b = cusum({5 6, 3 4});
print a, b;

Figure 95: Cumulative Sums

a
13712

b
511
1418


Last updated: May 07, 2026