Language Reference

MATTRIB Statement

associates printing attributes with matrices

MATTRIB name <ROWNAME=row-name>
           <COLNAME=column-name> <LABEL=label> <FORMAT=format>;

The inputs to the MATTRIB subroutine are as follows:

name
is a character matrix or quoted literal giving the name of a matrix.

row-name
is a character matrix or quoted literal specifying row names.

column-name
is a character matrix or quoted literal specifying column names.

label
is a character matrix or quoted literal associating a label with the matrix. The label argument has a maximum length of 256 characters.

format
is a valid SAS format.

The MATTRIB statement associates printing attributes with matrices. Each matrix can be associated with a ROWNAME= matrix and a COLNAME= matrix, which is used whenever the matrix is printed to label the rows and columns, respectively. The statement is written as the keyword MATTRIB followed by a list of one or more names and attribute associations. It is not necessary to specify all attributes. The attribute associations are applied to the previous name. Thus, the following statement gives a row name RA and a column name CA to a, and a column name CB to b:

  
    mattrib a rowname=ra colname=ca b colname=cb;
 
You cannot group names; although the following statement is valid, it does not associate anything with a.
  
    mattrib a b rowname=n;
 

The values of the associated matrices are not looked up until they are needed. Thus, they need not have values at the time the MATTRIB statement is specified. They can be specified later when the object matrix is printed. The attributes continue to bind with the matrix until reassigned with another MATTRIB statement. To eliminate an attribute, specify EMPTY as the name, for example, ROWNAME=EMPTY. Labels can be up to 40 characters long. Longer labels are truncated. Use the SHOW names statement to view current matrix attributes.

An example that uses the MATTRIB statement follows:

  
    rows='xr1':'xr5'; 
    print rows; 
  
                              ROWS 
                              xr1 xr2 xr3 xr4 xr5 
  
  
    cols='cl1':'cl5'; 
    print cols; 
  
                              COLS 
                              cl1 cl2 cl3 cl4 cl5 
  
  
    x={1 1 1 1,2 2 2 2,3 3 3 3}; 
    mattrib x rowname=(rows [1:3 ]) 
              colname=(cols [1:4]) 
              label={'matrix,x'} 
              format=5.2; 
    print x; 
  
                                  matrix,x 
                           cl1   cl2   cl3   cl4 
  
                   xr1     1.00  1.00  1.00  1.00 
                   xr2     2.00  2.00  2.00  2.00 
                   xr3     3.00  3.00  3.00  3.00
 

Previous Page | Next Page | Top of Page