Understanding the SAS/IML Language


Numeric Literals

To specify a matrix literal with multiple elements, enclose the elements in braces. Use commas to separate the rows of a matrix. For example, the following statements assign and print matrices of various dimensions:

x = {1 . 3 4 5 6};                   /* 1 x 6 row vector */
y = {1,2,3,4};                       /* 4 x 1 column vector */
z = 3#y;                             /* 3 times the vector y */
w = {1 2, 3 4, 5 6};                 /* 3 x 2 matrix */
print x, y z w;

Figure 3.1: Matrices Created from Numeric Literals

x
1 . 3 4 5 6

y z w  
1 3 1 2
2 6 3 4
3 9 5 6
4 12