| Understanding the Interactive Matrix Language |
The general form of a function is as follows:
| matrix inquiry functions | |
| return information about a matrix. For example, the ANY function returns a value of 1 if any of the elements of the argument matrix are nonzero. | |
| scalar functions | |
| operate on each element of the matrix argument. For example, the ABS function returns a matrix with elements that are the absolute values of the corresponding elements of the argument matrix. | |
| summary functions | |
| return summary statistics based on all elements of the matrix argument. For example, the SSQ function returns the sum of squares of all elements of the argument matrix. | |
| matrix arithmetic functions | |
| perform matrix algebraic operations on the argument. For example, the TRACE function returns the trace of the argument matrix. | |
| matrix reshaping functions | |
| manipulate the matrix argument and return a reshaped matrix. For example, the DIAG function returns a matrix with diagonal elements that are equal to the diagonal elements of a square argument matrix. All off-diagonal elements are zero. | |
| linear algebra and statistical functions | |
| perform linear algebraic functions on the matrix argument. For example, the GINV function returns the matrix that is the generalized inverse of the argument matrix. | |
| DIF | HBOUND | LAG | PUT | |||
| DIM | INPUT | LBOUND |
| MAX | RANK | SOUND | SUBSTR | |||
| MIN | REPEAT | SSQ | SUM |
The random number functions, UNIFORM and NORMAL,
are built-in and produce the same streams as the
RANUNI and RANNOR functions, respectively, of the DATA step.
For example, to create a
vector of random numbers, use the following statement:
x=uniform(repeat(0,10,1));
Also, SAS/IML software does not support
the OF clause of the SAS DATA step.
For example, the following statement cannot be interpreted properly in IML:
a=mean(of x1-x10); /* invalid in IML */
The term X1-X10 would be interpreted as
subtraction of the two matrix arguments rather
than its DATA step meaning, "X1 through X10."
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.