Understanding the SAS/IML Language


Defining a Matrix

A matrix is the fundamental structure in the SAS/IML language. A matrix is a two-dimensional array of numeric or character values. Matrices are useful for working with data and have the following properties:

  • Matrices can be either numeric or character. Elements of a numeric matrix are double-precision values. Elements of a character matrix are character strings of equal length.

  • The name of a matrix must be a valid SAS name.

  • Matrices have dimensions defined by the number of rows and columns.

  • Matrices can contain elements that have missing values (see the section Missing Values).

The dimensions of a matrix are defined by the number of rows and columns. An $n \times p$ matrix has $np$ elements arranged in n rows and p columns. The following nomenclature is standard in this book:

  • $1 \times 1$ matrices are called scalars.

  • $1 \times p$ matrices are called row vectors.

  • $n \times 1$ matrices are called column vectors.

  • The type of a matrix is "numeric" if its elements are numbers; the type is "character" if its elements are character strings. A matrix that has not been assigned values has an "undefined" type.