Language Reference


PROD Function

PROD (matrix1 <, matrix2, …, matrix15> );

The PROD function returns as a single numeric value the product of all nonmissing elements in all arguments. You can pass in as many as 15 numeric matrices as arguments. The PROD function checks for missing values and does not include them in the product. It returns missing if all values are missing.

For example, consider the following statements:

a = {2 1, . 3};
b = prod(a);
print b;

Figure 25.279: Output from the PROD Function

b
6



For a single argument with at least one nonmissing value, the PROD function is identical to the subscript reduction operator that computes the product. That is, prod(x) and x[#] both compute the product of the elements of x. See the section Subscript Reduction Operators for more information about subscript reduction operators.