CALL SUBTRACTMATRIX Routine

Performs an element-wide subtraction of two matrices or a matrix and a scalar.
Category: Matrix Operations
Requirement: All input and output matrices must have the same dimensions.

Syntax

CALL SUBTRACTMATRIX(X, Y, Z);

Required Arguments

X
specifies an input matrix with dimensions m x n (that is, X[m, n]) or a scalar.
Y
specifies an input matrix with dimensions m x n (that is, Y[m, n]) or a scalar.
Z
specifies an output matrix with dimensions m x n (that is, Z[m, n]), such that

Example

The following example uses the SUBTRACTMATRIX CALL routine:
options pageno=1 nodate;

proc fcmp;
   array mat1[3,2] (0.3, -0.78, -0.82, 0.54, 1.74, 1.2);
   array mat2[3,2] (0.2, 0.38, -0.12, 0.98, 2, 5.2);
   array result[3,2];
   call subtractmatrix (mat1, mat2, result);
   call subtractmatrix (2, mat1, result);
   put result=;
 quit;
Output from the SUBTRACTMATRIX CALL Routine
                                The SAS System                               1

                              The FCMP Procedure

result[1, 1]=1.7 result[1, 2]=2.78 result[2, 1]=2.82 result[2, 2]=1.46
result[3, 1]=0.26 result[3, 2]=0.8