MATTRIB
name <ROWNAME=row-name> <COLNAME=column-name> <LABEL=label> <FORMAT=format> ;
The MATTRIB subroutine associates printing attributes with matrices.
The input arguments to the MATTRIB subroutine are as follows:
is a character matrix or quoted literal that contains the name of a matrix.
is a character matrix or quoted literal that specifies row names.
is a character matrix or quoted literal that specifies column names.
is a character matrix or quoted literal that associates a label with the matrix. The label argument has a maximum length of 256 characters.
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 are 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 associates a row name RA and a column name CA to a
, and a column name CB to b
:
a = {1 2 3, 4 5 6}; ra = {"Row 1", "Row 2"}; ca = 'C1':'C3'; b = 1:4; cb = {"A" "B" "C" "D"}; mattrib a rowname=ra colname=ca b colname=cb; print a, b;
You cannot group names. The following statement does not associate anything with a
. In fact, it clears any attributes that were previously associated with a
.
mattrib a b colname=cb; print a, b;
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). Use the SHOW NAMES statement to view current matrix attributes.
The following example uses all options in the MATTRIB statement:
rows = "xr1":"xr3"; cols = "cl1":"cl4"; x = {1 1 1 1, 2 2 2 2, 3 3 3 3}; mattrib x rowname=rows colname=cols label={"My Matrix, x"} format=5.2; print x;
Figure 23.182: Matrix Attributes
My 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 |