Further Notes


Error Diagnostics

When an error occurs, a message is displayed in the SAS log. The message includes a description of the error, the operation being performed, and the line and column number of the statement in which the error occurred. The names of matrices that are involved in the operation are also displayed. Matrix names that begin with a number sign (#) or an asterisk (*) are temporary names that the IML procedure assigns.

Some errors can be caught at parse time. For example, syntax errors such as an incorrect number of arguments, unbalanced parentheses, and a missing semicolon are detected when the program is parsed.

When an error occurs, the operation is not completed and the result (if any) is not assigned a value. If an error occurs during execution of statements inside a module, a PAUSE statement is automatically issued. You can correct the error and resume execution of statements inside a module by submitting a RESUME statement .

The following list describes common errors and their associated error messages:

  • Referencing a matrix that has not been set to a value. For example, the following statement references a matrix that has no value:

    y = EmptyMatrix + 1;

    ERROR: (execution) Matrix has not been set to a value.

  • Making a subscripting error. For example, the following statements refer to an element that is not present in a matrix:

    x = 1:3; x[4] = 1;

    ERROR: (execution) Invalid subscript or subscript out of range.

  • Performing an operation that involves nonconformable matrix arguments. When you add, subtract, or multiply matrices, the dimensions of the matrices must satisfy certain conditions. Otherwise, the matrix operation is not defined. Let $\bA $ and $\bB $ be matrices. Then the following conditions must hold:

    • The elementwise operations $\bA +\bB $, $\bA -\bB $, $\bA \#  \bB $, and $\bA / \bB $ are defined if $\bA $ and $\bB $ are the same dimensions. If $\bA $ is an $n\times p$ matrix, the operations are also defined if $\bB $ is a $1\times p$ row vector, an $n\times 1$ column vector, or a $1\times 1$ scalar. Similarly, if $\bB $ is a matrix, $\bA $ can be a vector of appropriate dimensions or a scalar.

    • The matrix multiplication $\bA *\bB $ is defined if the number of columns of $\bA $ equals the number of rows of $\bB $.

    • The horizontal concatenation operation $\bA $ || $\bB $ is defined if the number of rows of $\bA $ equals the number of rows of $\bB $.

    • The vertical concatenation operation $\bA $ // $\bB $ is defined if the number of columns of $\bA $ equals the number of columns of $\bB $.

    For example, the following statements generate an error:

    x = 1:3; y = 1:4; m = x+y;

    ERROR: (execution) Matrices do not conform to the operation.

  • Passing a matrix of the wrong dimensions to function. For example, the following statement passes a vector to a function that is expecting a scalar argument:

    d = do(1, 2, 1:3); /* third arg must be scalar */

    ERROR: (execution) Argument should be a scalar.

  • Passing a matrix that is not square to a function (such as INV, DET, or SOLVE) that requires a square matrix. For example:

    v = eigval(1:3);

    ERROR: (execution) Matrix should be square.

  • Passing a matrix that is not symmetric to a function that requires a symmetric matrix. For example:

    call geneig(M, E, 1 2, 3 4, 1 2, 2 1);

    ERROR: (execution) Matrix should be symmetric.

  • Passing a matrix that is singular to functions that require a nonsingular matrix. For example:

    A = inv(1 1, 2 2);

    ERROR: (execution) Matrix should be non-singular.

  • Passing a matrix that is not positive definite or positive semidefinite to functions that require such matrices. For example:

    G = root(1 2, 2 3);

    ERROR: (execution) Matrix should be positive definite.

  • Attempting to allocate a matrix for which there is not enough RAM. (See the section Memory and Workspace.) For example:

    X = j(1e6, 1e6);

    ERROR: (execution) Unable to allocate sufficient memory.

  • Passing a numerical matrix to a function that expects a character matrix, or passing a character matrix to a function that expects a numerical matrix. For example:

    v = eigval(A B, C D);

    ERROR: (execution) Character argument should be numeric.