Understanding the Interactive Matrix Language

Commands

Commands are used to perform specific system actions, such as storing and loading matrices and modules, or to perform special data processing requests. The following table lists some commands and the actions they perform.

Command   Action
FREE frees a matrix of its values and increases available space
LOAD loads a matrix or module from the storage library
MATTRIB associates printing attributes with matrices
PRINT prints a matrix or message
RESET sets various system options
REMOVE removes a matrix or module from library storage
SHOW requests that system information be displayed
STORE stores a matrix or module in the storage library

These commands play an important role in SAS/IML software. With them, for example, you can control displayed output (with RESET PRINT, RESET NOPRINT, or MATTRIB) or get system information (with SHOW SPACE, SHOW STORAGE, or SHOW ALL).

If you are running short on available space, you can use commands to store matrices in the storage library, free the matrices of their values, and reload them later when you need them again, as shown in the following example.

Throughout this session, the right angle brackets (>) indicate statements that you submit; responses from IML follow. First, invoke the procedure at the input prompt. Then, create matrices a and b as matrix literals. Here are the statements:

  
    > proc iml; 
  
      IML Ready 
  
    > a={1 2 3, 4 5 6, 7 8 9}; 
    > b={2 2 2};
 
List the names and attributes of all your matrices with the SHOW NAMES command:
  
    > show names; 
  
      A             3 rows      3 cols num      8 
      B             1 row       3 cols num      8 
      Number of symbols = 2  (includes those without values)
 
Store these matrices in library storage with the STORE command, and release the space with the FREE command. To list the matrices and modules in library storage, use the SHOW STORAGE command. Here are the statements:
  
    > store a b; 
    > free a b; 
    > show storage; 
  
      Contents of storage = SASUSER.IMLSTOR 
      Matrices: 
       A        B 
  
      Modules:
 
The preceding output from the SHOW STORAGE statement indicates that you have two matrices in storage. Because you have not stored any modules in this session, there are no modules listed in storage. Return these matrices from the storage library with the LOAD command, as follows. (See Chapter 14 for details about storage.)

  
    > load a b;
 
End the session with the QUIT command:
  
    > quit; 
  
      Exiting IML
 

Data Management Commands

SAS/IML software has many data management commands that enable you to manage your SAS data sets from within the SAS/IML environment. These data management commands operate on SAS data sets. There are also commands for accessing external files. The following table lists some commands and the actions they perform:

Command   Action
APPEND adds records to an output SAS data set
CLOSE closes a SAS data set
CREATE creates a new SAS data set
DELETE deletes records in an output SAS data set
EDIT reads from or writes to an existing SAS data set
FIND finds records that meet some condition
LIST lists records
PURGE purges records marked for deletion
READ reads records from a SAS data set into IML variables
SETIN makes a SAS data set the current input data set
SETOUT makes a SAS data set the current output data set
SORT sorts a SAS data set
USE opens an existing SAS data set for Read access

These commands can be used to perform any necessary data management functions. For example, you can read observations from a SAS data set into a target matrix with the USE or EDIT command. You can edit a SAS data set, appending or deleting records. If you have generated data in a matrix, you can output the data to a SAS data set with the APPEND or CREATE command. See Chapter 6 and Chapter 7 for more information about these commands.

Previous Page | Next Page | Top of Page