Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Language Reference

PRINT Statement

prints matrix values

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

The inputs 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, using a comma (,) skips a single line and using a slash (/) skips to a new page.

[options]
are described below.
The PRINT statement prints the specified matrices or message. The options below 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];


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 RESET autoname statement to automatically label rows as ROW1, ROW2, and so on.)
   reset autoname;
For example, you can use the statement below to print a matrix called X in format 12.2 with columns labeled AMOUNT and NET PAY, and rows labeled DIV A and DIV B:
   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];
The output is
                       X           AMOUNT      NET PAY

                       DIV A        45.13        50.50
                       DIV B        75.38        90.83
To permanently associate the above options with a matrix name, refer to 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 folded, with the continuation lines identified by a colon(:).

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, see the description of the RESET statement. The example below shows how to print part of a matrix:
   y=1:10;
      /* prints first five elements of y*/
   print (y[1:5]) [format=5.1];


Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

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