Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Language Reference

Addition Operator:   +

adds corresponding matrix elements

matrix1 + matrix2
matrix + scalar

The addition infix operator (+) produces a new matrix containing elements that are the sums of the corresponding elements of matrix1 and matrix2. The element in the first row, first column of the first matrix is added to the element in the first row, first column of the second matrix, with the sum becoming the element in the first row, first column of the new matrix, and so on.

For example, the statements

   a={1 2,
      3 4};
   b={1 1,
      1 1};
   c=a+b;
produce the matrix C.
              C             2 rows      2 cols    (numeric)

                                   2         3
                                   4         5
In addition to adding conformable matrices, you can also use the addition operator to add a matrix and a scalar or two scalars. When you use the matrix + scalar (or scalar + matrix) form, the scalar value is added to each element of the matrix to produce a new matrix.

For example, you can obtain the same result as you did in the previous example with the statement

   c=a+1;
When a missing value occurs in an operand, IML assigns a missing value for the corresponding element in the result.

You can also use the addition operator on character operands. In this case, the operator does elementwise concatenation exactly as the CONCAT function.

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.