The Interactive Matrix Language (IML) provides a complete environment for performing matrix manipulations. This can be used to manipulate SAS data sets and perform a complete statistical analysis. This section introduces the basic features. Accessing SAS datasets in IML and the IML macro programming language, and IML graphics programming are discussed elsewhere.
Start IML by issuing the command proc iml; on a line in the
program window. Don't forget to use LOCALS--SUBMIT to actually
have the command processed. Leave IML by issuing the command
quit;.
NOTE: Use of a data step or another procedure will terminate the IML session.
The native data elements in IML are matrices. The command
a={1 2, 3 4, 5 6}; creates a 3x2 matrix a with the
indicated entries. The entries may be spread accross several
lines, so it may be easier to input large matrices as
a={
1 2,
3 4,
5 6};
Note that spaces separate entries in each row, and commas are used to separate rows.
The entries of a matrix can be all numbers or all character strings. The two types cannot be mixed in the same matrix.
Some of the typical IML commands are listed here.
The print statement is used to print the indicated matrices in the output window. Typical usage is
print a b[rowname=name format=4.1];
which will print the matrix a in the default format, and the
matrix b formatted with 4 significant digits one of which
follows the decimal. The matrix b will also have the vector name
used as names for the rows.
The reset statement specifies certain options for printing and numeric calculation.
Labels, row names, column names, and numeric formats can be associated with a matrix through the mattrib statement.
The full list of SAS functions is available online under HELP--SAS SYSTEM-- SAS LANGUAGE--SAS FUNCTIONS. A partial listing can be found here.
As usual, comments can be enclosed between /* and */.
Matrices can be stored on disk and retrieved for later use by using the store and load commands.
For further information see the online help under HELP--SAS SYSTEM--MODELING AND ANALYSIS TOOLS--INTERACTIVE MATRIX LANGUAGE or Chapters 2 and 4 of SAS/IML Software.
Copyright © 1997 by Jerry Alan Veeh. All rights reserved.