PRINT Statement

PRINT <matrices> <*>(expression) <*>"message" <*>pointer-controls <[options]> ;

The PRINT statement displays the values of matrices or literals.

The arguments to the PRINT statement are as follows:

matrices

are the names of matrices.

(expression)

is an expression in parentheses that is evaluated. The result of the evaluation is printed. The evaluation of a subscripted matrix used as an expression results in printing the submatrix.

message

is a message in quotes.

pointer-controls

control the pointer for printing. For example, a comma (,) skips a single line and a slash (/) skips to a new page.

options

are described in the following list.

The following options can appear in the PRINT statement. They are specified in brackets after the matrix name to which they apply.

COLNAME=matrix

specifies the name of a character matrix whose first ncol elements are to be used for the column labels of the matrix to be printed, where ncol is the number of columns in the matrix. You can also use the RESET AUTONAME statement to automatically label columns as COL1, COL2, and so on.

FORMAT=format

specifies a valid SAS or user-defined format to use in printing the values of the matrix. For example:

print x[format=5.3];
LABEL=label

specifies the name of a scalar character matrix or literal to use as a label when printing the matrix. For example:

print x[label="Net Pay"];
ROWNAME=matrix

specifies the name of a character matrix whose first nrow elements are to be used for the row labels of the matrix to be printed, where nrow is the number of rows in the matrix and where the scan to find the first nrow elements goes across row 1, then across row 2, and so forth through row $n$. You can also use the following RESET AUTONAME statement to automatically label rows as ROW1, ROW2, and so on:

reset autoname;

For example, the following statements print a matrix in the 12.2 format with column and row labels:

x = {45.125 50.500,
     75.375 90.825};
r = {"Div A"  "Div B"};
c = {"Amount" "Net Pay"};
print x[rowname=r colname=c format=12.2];

Figure 24.272: Matrix with Row and Column Labels

x
  Amount Net Pay
Div A 45.13 50.50
Div B 75.38 90.83


To permanently associate the preceding options with a matrix name, see the description of the MATTRIB statement.

If there is not enough room to print all the matrices across the page, then one or more matrices are printed out in the next group. If there is not enough room to print all the columns of a matrix across the page, then the columns are continued on a subsequent line.

The spacing between adjacent matrices can be controlled by the SPACES= option of the RESET statement. The FW= option of the RESET statement can be used to control the number of print positions used to print each numeric element. For more print-related options, including the PRINTADV option, see the description of the RESET statement.

To print part of a matrix or a temporary expression, enclose the expression in parentheses:

y=1:10;
print (y[1:3])[format=5.1]; /* prints first few elements */
print (sum(y))[label="sum"];

Figure 24.273: Printing Temporary Matrices

1.0
2.0
3.0

sum
55