Chapter Contents |
Previous |
Next |
The PRINT Procedure |
PROC PRINT <option(s)>; |
To do this | Use this option | |
---|---|---|
Specify the input data set | DATA= | |
Control general format | ||
Write a blank line between observations | DOUBLE | |
Print the number of observations in the data set, in BY groups, or both, and specify explanatory text to print with the number | N= | |
Suppress the column in the output that identifies each observation by number | NOOBS | |
Specify a column header for the column that identifies each observation by number | OBS= | |
Round unformatted numeric values to two decimal places | ROUND | |
Control page format | ||
Format the rows on a page | ROWS= | |
Use each variable's formatted width as its column width on all pages | WIDTH=UNIFORM | |
Control column format | ||
Control the orientation of the column headings | HEADING= | |
Use variables' labels as column headings | LABEL or SPLIT= | |
Specify the split character, which controls line breaks in column headings | SPLIT= | |
Determine the column width for each variable | WIDTH= |
Options |
Main discussion: | Input Data Sets |
Alias: | D |
Restriction: | This option has no effect on the HTML output. |
Featured in: | Selecting Variables to Print |
Alias: | H |
Alias: | V |
Default: | Headings are either all horizontal or
all vertical. If you omit HEADING=, PROC PRINT determines the direction of
the column headings as follows:
|
Alias: | L |
Default: | If you omit LABEL, PROC PRINT uses the variable's name as the column heading even if the PROC PRINT step contains a LABEL statement. If a variable does not have a label, PROC PRINT uses the variable's name as the column heading. |
Interaction: | By default, if you specify LABEL and at least one variable has a label, PROC PRINT prints all column headings horizontally. Therefore, using LABEL may increase the number of pages of output. (Use HEADING=VERTICAL in the PROC PRINT statement to print vertical column headings.) |
Interaction: | PROC PRINT sometimes conserves space by splitting labels across multiple lines. Use SPLIT= in the PROC PRINT statement to control where these splits occur. You do not need to use LABEL if you use SPLIT=. |
Tip: | To create a blank column header for a variable,
use this LABEL statement in your PROC PRINT step:
label variable-name='00'x; |
See also: | For information on using the LABEL
statement to create temporary labels in procedures see Statements with the Same Function in Multiple Procedures .
For information on using the LABEL statement in a DATA step to create permanent labels, see the section on statements in SAS Language Reference: Dictionary. |
Featured in: | Creating Separate Sections of a Report for Groups of Observations |
Note: The SAS system option LABEL must
be in effect in order for any
procedure to use labels. For more information see the section on system options
in SAS Language Reference: Dictionary
If you use the N option ... | PROC PRINT ... |
---|---|
with neither a BY nor a SUM statement | prints the number of observations in the data set at the end of the report and labels the number with the value of string-1. |
with a BY statement | prints the number of observations in the BY group at the end of each BY group and labels the number with the value of string-1. |
with a BY statement and a SUM statement | prints the number of observations in the BY group at the end of each BY group and prints the number of observations in the data set at the end of the report. The numbers for BY groups are labeled with string-1; the number for the entire data set is labeled with string-2. |
Featured in: | Customizing Text in Column Headers (alone) |
Summing Numeric Variables with One BY Group (with a BY statement and a SUM statement)
Featured in: | Creating Separate Sections of a Report for Groups of Observations |
Tip: | OBS= honors the split character (see the discussion of SPLIT= ). |
Featured in: | Customizing Text in Column Headers |
If you omit ROUND, PROC PRINT adds the actual values of the rows to obtain the sum even though it displays the formatted (rounded) values. Any sums are also rounded by the format, but they include only one rounding error, that of rounding the sum of the actual values. The ROUND option, on the other hand, rounds values before summing them, so there may be multiple rounding errors. The results without ROUND are more accurate, but ROUND is useful for published reports where it is important for the total to be the sum of the printed (rounded) values.
Be aware that the results from PROC PRINT with the ROUND option may differ from the results of summing the same data with other methods such as PROC MEANS or the DATA step. Consider a simple case in which
Depending on how you calculate the sum, you can get three different answers: 0.02, 0.01, and 0.016. Three Methods of Summing Variables shows the results of calculating the sum with PROC PRINT (without and with the ROUND option) and PROC MEANS.
Three Methods of Summing Variables
Notice that the sum produced without the ROUND option (.02) is closer to the actual result (0.16) than the sum produced with ROUND (0.01). However, the sum produced with ROUND reflects the numbers displayed in the report.
Alias: | R |
Restriction: | Physical page size does not mean the same thing in HTML output as it does in traditional procedure output. Therefore, HTML output from PROC PRINT appears the same whether or not you use ROWS=. |
Tip: | The PAGE value can reduce the number of pages in the output if the data set contains large numbers of variables and observations. However, if the data set contains a large number of variables but few observations, the PAGE value can increase the number of pages in the output. |
See also: | Page Layout for discussion of the default layout. |
Featured in: | Controlling the Layout of a Report with Many Variables |
Alias: | S= |
Interaction: | You do not need to use both LABEL and SPLIT= because SPLIT= implies the use of labels. |
Interaction: | The OBS= option honors the split character. (See the discussion of OBS= ). |
Featured in: | Customizing Text in Column Headers |
Note: PROC PRINT does
not split labels of BY variables in the heading
preceding each BY group even if you specify SPLIT=. Instead, PROC PRINT treats
the split character as part of the label. Therefore, you probably want to
avoid using a split character when you are using the BY statement.
Tip: | Using WIDTH=FULL can reduce execution time. |
Alias: | MIN |
Alias: | U |
Tip: | If the data set is large and you want a uniform report, you can save computer resources by using formats that explicitly specify a field width so that PROC PRINT reads the data only once. |
Tip: | WIDTH=UNIFORM is the same as UNIFORM. |
Restriction: | When not all variables have formats that explicitly specify a width, you cannot use WIDTH=UNIFORM with an engine that supports concurrent access if another user is updating the data set at the same time. |
Alias: | UBY |
Restriction: | You cannot use UNIFORMBY with a sequential data set. |
Default: | If you omit WIDTH= and do not specify the UNIFORM option, PROC PRINT individually constructs each page of output. The procedure analyzes the data for a page and decides how best to display them. Therefore, column widths may differ from one page to another. |
Tip: | Column width is affected not only by variable width but also by the length of column headings. Long column headings may lessen the usefulness of WIDTH=. |
See also: | For a discussion of default column widths, see Column Width . |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.