Command Statements |
Command statements 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.
Statement |
Description |
---|---|
Frees memory associated with a matrix |
|
Loads a matrix or module from a storage library |
|
Associates printing attributes with matrices |
|
Prints a matrix or message |
|
Sets various system options |
|
Removes a matrix or module from library storage |
|
Displays system information |
|
Stores a matrix or module in the storage library |
These commands play an important role in SAS/IML software. You can use them to control information displayed about matrices, symbols, or modules.
If a certain computation requires almost all of the memory on your computer, you can use commands to store extraneous matrices in the storage library, free the matrices of their values, and reload them later when you need them again. For example, the following statements define several matrices:
proc iml; a = {1 2 3, 4 5 6, 7 8 9}; b = {2 2 2}; show names;
SYMBOL ROWS COLS TYPE SIZE ------ ------ ------ ---- ------ a 3 3 num 8 b 1 3 num 8 Number of symbols = 2 (includes those without values) |
Suppose that you want to compute a quantity that does not involve the a matrix or the b matrix. You can store a and b in a 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 (or the STORAGE function), as shown in the following statements:
store a b; /* store the matrices */ show storage; /* make sure the matrices are saved */ free a b; /* free the RAM */
The output from the SHOW STORAGE statement (see Figure 3.4) indicates that there are two matrices in storage. (There are no modules in storage for this example.)
Contents of storage library = WORK.IMLSTOR Matrices: A B Modules: |
You can load these matrices from the storage library into RAM with the LOAD command, as shown in the following statement:
load a b;
See Chapter 17, Storage Features, for more details about storing modules and matrices.
SAS/IML software has many 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.
Statement |
Description |
---|---|
Adds records to an output SAS data set |
|
Closes a SAS data set |
|
Creates a new SAS data set |
|
Deletes records in an output SAS data set |
|
Reads from or writes to an existing SAS data set |
|
Finds records that satisfy some condition |
|
Lists records |
|
Purges records marked for deletion |
|
Reads records from a SAS data set into IML matrices |
|
Sets a SAS data set to be the input data set |
|
Sets a SAS data set to be the output data set |
|
Sorts a SAS data set |
|
Opens an existing SAS data set for reading |
These commands can be used to perform data management. 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 and append or delete records. If you have a matrix of values, you can output the values to a SAS data set with the APPEND command. See Chapter 7, Working with SAS Data Sets, and Chapter 8, File Access, for more information about these commands.