Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Language Reference

Subscripts:   [ ]

select submatrices

matrix[rows,columns]
matrix[elements]

Subscripts are used with matrices to select submatrices, where rows and columns are expressions that evaluate to scalars or numeric vectors. These expressions contain valid subscript values of rows and columns in the argument matrix. A subscripted matrix can appear on the left side of the equal sign. The dimensions of the target submatrix must conform to the dimensions of the source matrix. See Chapter 4, "Working with Matrices," for further information.

For example, the statements

   x={1 2 3,
      4 5 6,
      7 8 9};
   a=3;
   m=x[2,a];
select the element in the second row and third column of X and produce the matrix M:
               M             1 row      1 col    (numeric)

                                         6
The statements
   a=1:3;
   m=x[2,a];
select row 2, and columns 1 through 3 of X, producing the matrix M:
               M             1 row      3 cols    (numeric)

                               4         5         6

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.