Working with SAS Data Sets


Select Variables with the VAR Clause

Several SAS/IML statements support a VAR clause that specifies variables to use for subsequent processing. The VAR clause is supported by the following statements:

The general form of the VAR clause is

  • VAR vars;

The argument vars is one of the following:

  • a literal matrix that contains variable names

  • a character matrix that contains variable names

  • an expression in parentheses that yields variable names

  • one of the following keywords:

    _ALL_

    for all variables

    _CHAR_

    for all character variables

    _NUM_

    for all numeric variables

The following examples demonstrate ways to use the VAR clause:

proc iml;
use Sashelp.Class;
read all var {age sex};        /* a literal matrix of names        */
varNames = {"weight" "height"};
read all var varNames;         /* a matrix that contains the names */
read all var _NUM_ into X;     /* a keyword                        */
close Sashelp.Class;

x1 = X[,1]; x2 = X[,2]; x3 = X[,3];
create Test var ("x1":"x3");   /* an expression                    */
append;
close Test;