Listing SAS/IML variables


Did you know that you can display a list of all the SAS/IML variables (matrices) that are defined in the current session? The SHOW statement performs this useful task. For example, the following statements define three matrices:

proc iml;
fruit = {"apple", "banana", "pear"};
k = 1:3;
x = j(1E5, 100); /** 10 million elements **/

If you want to display the names of all SAS/IML variables in the current environment, use the SHOW NAMES statement:

show names;

The displayed table gives the name of each matrix along with the matrix dimensions and the type of the matrix. (Notice that the names of the matrices are listed under a column that says "SYMBOL." This is the computer science terminology for "name of a variable in a program.")

The NAMES keyword requests a display for all variables. You can also list the characteristics of specific variables by typing the names of variables after the SHOW statement:

show x;

Local Symbol Tables

If you use the SHOW statement in the main SAS/IML program, you will get information about matrices that are defined at the main scope of the program (also called global scope). If you use the SHOW statement inside a SAS/IML module, you will see information about the variables local to that module.

For example, the following statements define a SAS/IML module that does nothing except define some local variables and return:

start MyMod(x);
   y = 1:5;
   g = {1 2, 3 4};
   show names;
run MyMod( "test" );

Notice that the local variable x is the argument to the module. For this example, x is a scalar character matrix, whereas the x variable defined at the global scope is a large numeric matrix.

Displaying Other System Information

The SHOW statement has other keywords that enable you to display information about system memory, data sets, and modules. See the documentation of the SHOW Statement for further details.


About Author

Rick Wicklin

Distinguished Researcher in Computational Statistics

Rick Wicklin, PhD, is a distinguished researcher in computational statistics at SAS and is a principal developer of SAS/IML software. His areas of expertise include computational statistics, simulation, statistical graphics, and modern methods in statistical data analysis. Rick is author of the books Statistical Programming with SAS/IML Software and Simulating Data with SAS.

Leave A Reply

Back to Top