SAS Institute. The Power to Know

SAS/IML(R) 9.2 User's Guide

Previous | Next
Understanding the Interactive Matrix Language

Matrix Literals

A matrix literal is a matrix represented by its values. When you represent a matrix with a literal, you are simply specifying the values of each element of the matrix. A matrix literal can have a single element (a scalar), or it can have many elements arranged in a rectangular form (rows x columns). The matrix can be numeric (all elements are numeric) or character (all elements are character). The dimension of the matrix is automatically determined by the way you punctuate the values.

If there are multiple elements, you use braces ({ }) to enclose the values and commas to separate the rows. Within the braces, values must be either all numeric or all character. If you use commas to create multiple rows, all rows must have the same number of elements (columns).

The values you input can be any of the following:

  • a number, with or without decimal points, possibly in scientific notation (such as 1E-5)
  • a character string. Character strings can be enclosed in either single quotes (') or double quotes ("), but they do not need to have quotes. Quotes are required when there are no enclosing braces or when you want to preserve case, special characters, or blanks in the string. If the string has embedded quotes, you must double them (for example, WORD='Can''t'). Special characters can be any of the following: ?   =   *   :   (   ).
  • a period (.), representing a missing numeric value
  • numbers in brackets ([ ]), representing repetition factors
Previous | Next | Top of Page