Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Language Reference

Logical Operators:   &   |   ^

perform elementwise logical comparisons

matrix1&matrix2
matrix&scalar
matrix1|matrix2
matrix|scalar
^matrix

The AND logical operator (&) compares two matrices, element by element, to produce a new matrix. An element of the new matrix is 1 if the corresponding elements of matrix1 and matrix2 are both nonzero; otherwise, it is a zero.

An element of the new matrix produced by the OR operator (|) is 1 if either of the corresponding elements of matrix1 and matrix2 is nonzero. If both are zero, the element is zero.

The NOT prefix operator (^) examines each element of a matrix and produces a new matrix containing elements that are ones and zeros. If an element of matrix equals 0, the corresponding element in the new matrix is 1. If an element of matrix is nonzero, the corresponding element in the new matrix is 0.

The following statements illustrate the use of these logical operators:

   z=x&r;
   if a|b then print c;
   if ^m then link x1;

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

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