SAS/IML Software: Features
Features
Matrices and Matrix Operators
The fundamental IML data object is a two-dimensional (row-by-column) numeric or character matrix. Matrices are useful for
representing data and are very efficient for working with data. For example, suppose you measured the daily high
temperatures in September for six different cities and want to convert the readings from Fahrenheit to Celsius. You could
write code such as
do i=1 to 30;
do j=1 to 6;
C[i,j]=5*(F[i,j]-32)/9;
end;
end;
where C[1,6] is the temperature in Celsius on September 1 for city 6. Such operations can be very slow and difficult to
program for complex formulas and large datasets; however, in SAS/IML you load your data into matrix F and simply write
C=5*(F-32)/9;
Basic operators are provided that perform: arithmetic operations on each element of the matrix (elementwise operations, as
illustrated in the previous example), matrix operations, concatenation of matrices, comparisons between and within matrices,
subscripting of matrices, and subscript reduction (for example, take the sum of squares of each row of a matrix).
These statements direct the flow of execution of IML statements, and enable program modularization. The control statements
include IF-THEN...ELSE, DO...END, iterative DO, DO WHILE, DO UNTIL, GOTO, LINK, RETURN, STOP, and ABORT.
The power of the SAS/IML language is released with the many matrix functions and call routines provided, ranging from
general matrix functions to complex numerical integration and optimization routines. The following lists some of the
operations that can be performed:
-
absolute values, exponentials, remainders, powers of matrix elements
-
find elements in a matrix satisfying given conditions
-
cumulative sums, horizontal direct product, and trace
-
create block diagonal, identity, diagonal, transposed matrices
-
reshape a matrix
-
find set difference, set union, or set intersection of matrices; remove duplicates from matrices
-
solve an ordinary differential equation
-
perform numerical integration
-
compute eigenvalues and eigenvectors for symmetric and unsymmetric matrices; create orthonormal eigenvectors
-
compute inverses, generalized inverses, Moore-Penrose inverses, and determinants
-
compute Gram-Schmidt orthonormal factorization
-
perform Cholesky, singular value, and complete orthogonal decomposition
-
perform QR decomposition by Householder rotation or the Gram-Schmidt process
-
solve linear programs, linear systems, and systems of linear equations
-
compute the first nonzero roots of a Bessel function of the first kind and the derivative of the Bessel function at each
root
-
perform discrete sequential tests
-
compute ARMA model autocovariance sequence, log likelihood and residuals
-
simulate a univariate ARMA time series
-
compute autocovariance estimates for time series
-
generate a Hankel ,Toeplitz, or block Toeplitz matrix
-
perform finite Fourier transformations and inverse FFTs
-
Kalman filtering
-
perform covariance filtering and prediction
-
perform fixed-interval smoothing
-
perform diffuse covariance filtering and prediction
-
perform diffuse fixed-interval smoothing
-
TIMSAC (TIMe Series Analysis and Control) routines (developed by the Institute of
Statistical Mathematics, Japan)
-
Bayesian seasonal adjustment modeling
-
time series decomposition analysis
-
locally stationary univariate and multivariate AR model fitting
-
univariate, multivariate, and periodic AR model fitting
-
ARMA model forecasting and forecast error variance
-
polynomial roots or ARMA coefficients computation
-
time-varying coefficient AR model estimation
-
solve ordinary differential equations
-
perform numerical integration
-
nonlinear optimization
-
optimization methods available:
-
Conjugate Gradient Method
-
Double Dogleg Method
-
Nelder-Mead Simplex Method
-
Newton-Raphson Method
-
Newton-Raphson Ridge Method
-
(Dual) Quasi-Newton Method
-
Quadratic Optimization Method
-
Trust-Region Method
-
methods for solving nonlinear least-squares problems:
-
Levenberg-Marquardt Least-Squares Method
-
Hybrid Quasi-Newton Least-Squares Methods
-
compute finite difference approximations for first- and second-order derivatives
-
determine a feasible point subject to boundary and linear constraints
You can extend the power of SAS/IML by writing your own functions and routines and storing them as "modules" in
libraries. Libraries can contain both functions and subroutines; functions can be invoked in assignment statements or
expressions, while subroutines can be invoked using CALL or RUN statements. IML automatically loads, resolves, and executes
a module when you use it.
The IMLMLIB Module Library contains several modules which may be used as though they were built-in functions of IML. The
IMLMLIB modules enable you to:
-
convert a matrix into a column vector
-
compute correlation coefficients
-
draw box and whisker diagrams
-
draw probability contours for x-y data
-
draw scatter plots of x-y data
-
compute the median of numeric data
-
perform quadratic regression
-
compute quartiles
-
perform regression analysis
-
convert a matrix into a row vector
-
replace substrings
-
standardize numeric data
-
print matrices in tabular format
A powerful set of commands, called graphics primitives, are provided to create customized displays. Several basic commands
are GDRAW (for drawing a line), GPOINT (for plotting points), and GPOLY (for drawing a polygon). A set of attributes such as
color and linestyle can be associated with each primitive. Collections of graphics primitives can be saved as a segment,
which can be included in subsequent graphs; graphs can be included on the same page.
Statistics and Operations Research Home Page | SAS/IML Software