Chapter Contents

Previous

Next
The PRINT Procedure

PROC PRINT Statement


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

DATA=SAS-data-set
specifies the SAS data set to print.
Main discussion: Input Data Sets

DOUBLE
writes a blank line between observations.
Alias: D
Restriction: This option has no effect on the HTML output.
Featured in: Selecting Variables to Print

HEADING=direction
controls the orientation of the column headings, where direction is one of the following:

HORIZONTAL
prints all column headings horizontally.
Alias: H

VERTICAL
prints all column headings vertically.
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:

  • If you do not use LABEL, spacing dictates whether column headings are vertical or horizontal.

  • If you use LABEL and at least one variable has a label, all headings are horizontal.

LABEL
uses variables' labels as column headings.
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  [cautionend]

N<="string-1" <"string-2">>
prints the number of observations in the data set, in BY groups, or both and specifies explanatory text to print with the number.

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)
Creating Separate Sections of a Report for Groups of Observations (with a BY statement)

Summing Numeric Variables with One BY Group (with a BY statement and a SUM statement)

NOOBS
suppresses the observation number in the output.
Featured in: Creating Separate Sections of a Report for Groups of Observations

OBS="column-header"
specifies a column header for the column that identifies each observation by number.
Tip: OBS= honors the split character (see the discussion of SPLIT= ).
Featured in: Customizing Text in Column Headers

ROUND
rounds unformatted numeric values to two decimal places. (Formatted values are already rounded by the format to the specified number of decimal places.) For both formatted and unformatted variables, PROC PRINT uses these rounded values to calculate any sums in the report.

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

[IMAGE]

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

CAUTION:
Do not use ROUND with PICTURE formats. ROUND is for use with numeric values. SAS procedures treat variables that have picture formats as character variables. Using ROUND with such variables may lead to unexpected results.  [cautionend]

ROWS=page-format
formats rows on a page. Currently, PAGE is the only value that you can use for page-format:

PAGE
prints only one row of variables for each observation per page. When you use ROWS=PAGE, PROC PRINT does not divide the page into sections; it prints as many observations as possible on each page. If the observations do not fill the last page of the output, PROC PRINT divides the last page into sections and prints all the variables for the last few observations.

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

SPLIT='split-character'
specifies the split character, which controls line breaks in column headers. It also uses labels as column headers. PROC PRINT breaks a column heading when it reaches the split character and continues the header on the next line. The split character is not part of the column heading although each occurrence of the split character counts toward the 256-character maximum for a label.
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.  [cautionend]

UNIFORM
See WIDTH=UNIFORM .

WIDTH=column-width
determines the column width for each variable. The value of column-width must be one of the following:

FULL
uses a variable's formatted width as the column width. If the variable does not have a format that explicitly specifies a field width, PROC PRINT uses the default width. For a character variable, the default width is the length of the variable. For a numeric variable, the default width is 12. When you use WIDTH=FULL, the column widths do not vary from page to page.
Tip: Using WIDTH=FULL can reduce execution time.

MINIMUM
uses for each variable the minimum column width that accommodates all values of the variable.
Alias: MIN

UNIFORM
uses each variable's formatted width as its column width on all pages. If the variable does not have a format that explicitly specifies a field width, PROC PRINT uses the widest data value as the column width. When you specify WIDTH=UNIFORM, PROC PRINT normally needs to read the data set twice. However, if all the variables in the data set have formats that explicitly specify a field width (for example, BEST12. but not BEST.), PROC PRINT reads the data set only once.
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.

UNIFORMBY
formats all columns uniformly within a BY group, using each variable's formatted width as its column width. If the variable does not have a format that explicitly specifies a field width, PROC PRINT uses the widest data value as the column width.
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.