Chapter Contents |
Previous |
Next |
Understanding the Language |
Assignment statements create matrices by evaluating expressions and assigning the results to a matrix. The expressions can be composed of operators (for example, matrix multiplication) or functions (for example, matrix inversion) operating on matrices. Because of the nature of linear algebraic expressions, the resulting matrices automatically acquire appropriate characteristics and values. Assignment statements have the general form
a=sqrt(b);assigns the square root of each element of B to the corresponding element of A.
The statement
y=inv(x);calls the INV function to compute the inverse matrix of X and assign the results to Y.
The statement
r=rank(x);creates a matrix R with elements that are the ranks of the corresponding elements of X.
The three types of operators are as follows:
y=x#(x>0);This assignment statement creates a matrix Y in which each negative element of the matrix X is replaced with zero. The statement actually has two expressions evaluated. The expression (X>0) is a many-to-one operation that compares each element of X to zero and creates a temporary matrix of results; an element of the temporary matrix is 1 when the corresponding element of X is positive, and 0 otherwise. The original matrix X is then multiplied elementwise by the temporary matrix, resulting in the matrix Y.
For a complete listing and explanation of operators, see Chapter 17, "Language Reference."
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.