Previous Page | Next Page

Creating Detail and Summary Reports with the REPORT Procedure

Review of SAS Tools


PROC REPORT Statements

PROC REPORT <DATA=SAS-data-set><option(s)>;
BREAK location break-variable </option(s)>;
COLUMN column-specification(s);
DEFINE report-item /<usage> <option(s)>;
RBREAK location</option(s)>;
TITLE<n> <'title'>;
WHERE where-expression;
PROC REPORT <DATA=SAS-data-set> <option(s)>;

starts the procedure. If no other statements are used, then SAS shows all variables in the SAS-data-set in a detail report in the REPORT window. If the data set contains only numeric data, then PROC REPORT shows all variables in a summary report. Other statements, listed below, enable you to control the structure of the report.

You can specify the following options in the PROC REPORT statement:

COLWIDTH=column-width

specifies the default number of characters for columns that contain computed variables or numeric data set variables.

DATA=SAS-data-set

names the SAS data set that PROC REPORT uses. If you omit DATA=, then PROC REPORT uses the most recently created data set.

HEADLINE

inserts a line of hyphens (-) under the column headers at the top of each page of the report.

HEADSKIP

inserts a blank line beneath all column headers (or beneath the line that the HEADLINE option inserts) at the top of each page of the report.

SPACING=space-between-columns

specifies the number of blank characters between columns. For each column, the sum of its width and the blank characters between it and the column to its left cannot exceed the line size.

SPLIT='character'

specifies the split character. PROC REPORT breaks a column header when it reaches that character and continues the header on the next line. The split character itself is not part of the column header, although each occurrence of the split character is counted toward the 256-character maximum for a label.

WINDOWS|NOWINDOWS

selects a windowing or nonwindowing environment.

When you use WINDOWS, SAS opens the REPORT window, which enables you to modify a report repeatedly and to see the modifications immediately. When you use NOWINDOWS, PROC REPORT runs without the REPORT window and sends its results to the SAS procedure output.

BREAK location break-variable </option(s)>;

produces a default summary at a break (a change in the value of a GROUP or ORDER variable). The information in a summary applies to a set of observations. The observations share a unique combination of values for the break variable and all other GROUP or ORDER variables to the left of the break variable in the report.

You must specify the following arguments in the BREAK statement:

location

controls the placement of the break lines, where location is

AFTER

places the break lines immediately after the last row of each set of rows that have the same value for the break variable.

BEFORE

places the break lines immediately before the first row of each set of rows that have the same value for the break variable.

break-variable

is a GROUP or ORDER variable. PROC REPORT writes break lines each time the value of this variable changes.

You can specify the following options in the BREAK statement:

OL

inserts a line of hyphens (-) above each value that appears in the summary line.

SKIP

writes a blank line for the last break line.

SUMMARIZE

writes a summary line in each group of break lines.

SUPPRESS

suppresses the printing of the value of the break variable in the summary line, and of any underlining or overlining in the break lines.

COLUMN <column-specification(s)>;

identifies items that form columns in the report and describes the arrangement of all columns. You can specify the following column-specification(s) in the COLUMN statement:

  • report-item(s)

  • report-item-1, report-item-2 <. . . , report-item-n>

where report-item identifies items that form columns in the report. A report-item is either the name of a data set variable, a computed variable, or a statistic.
report-item-1, report-item-2 <. . . , report-item-n>

identifies report items that collectively determine the contents of the column or columns. These items are said to be stacked in the report because each item generates a header, and the headers are stacked one above the other. The header for the leftmost item is on top. If one of the items is an ANALYSIS variable, then a computed variable, or a statistic, its values fill the cells in that part of the report. Otherwise, PROC REPORT fills the cells with frequency counts.

DEFINE report-item / <usage> <option(s)>;

describes how to use and display a report item. A report item is either the name or alias (established in the COLUMN statement) of a data set variable, a computed variable, or a statistic. The usage of the report item is

  • ACROSS

  • ANALYSIS

  • COMPUTED

  • DISPLAY

  • GROUP

  • ORDER

You can specify the following options in the DEFINE statement:

CENTER

centers the formatted values of the report item within the column width, and centers the column header over the values.

column-header

defines the column header for the report item. Enclose each header in single or double quotation marks. When you specify multiple column headers, PROC REPORT uses a separate line for each one. The split character also splits a column header over multiple lines.

DESCENDING

reverses the order in which PROC REPORT displays rows or values of a GROUP, ORDER, or ACROSS variable.

FORMAT=format

assigns a SAS format or a user-defined format to the report item. This format applies to report-item as PROC REPORT displays it; the format does not alter the format associated with a variable in the data set.

ORDER=DATA | FORMATTED | FREQ | INTERNAL

orders the values of a GROUP, ORDER, or ACROSS variable according to the specified order, where

DATA

orders values according to their order in the input data set.

FORMATTED

orders values by their formatted (external) values. By default, the order is ascending.

FREQ

orders values by ascending frequency count.

INTERNAL

orders values by their unformatted values, which yields the same order that PROC SORT would yield. This order is operating environment dependent. This sort sequence is particularly useful for displaying dates chronologically.

RIGHT

right-justifies the formatted values of the specified report item within the column width and right-justifies the column headers over the values. If the format width is the same as the width of the column, then RIGHT has no affect on the placement of values.

SPACING=horizontal-positions

defines the number of blank characters to leave between the column that is being defined and the column immediately to its left. For each column, the sum of its width and the blank characters between it and the column to its left cannot exceed the line size.

statistic

associates a statistic with an ANALYSIS variable. PROC REPORT uses this statistic to calculate values for the ANALYSIS variable for the observations represented by each cell of the report. If you do not associate a statistic with the variable, then PROC REPORT calculates the SUM statistic. You cannot use statistic in the definition of any other kind of variable.

WIDTH=column-width

defines the width of the column in which PROC REPORT displays report-item.

RBREAK location </option(s)>;

produces a default summary at the beginning or end of a report.

You must specify the following argument in the RBREAK statement:

location

controls the placement of the break lines and is either

AFTER

places the break lines at the end of the report.

BEFORE

places the break lines at the beginning of the report.

You can specify the following options in the RBREAK statement:

DOL

specifies to double overline each value that appears in the summary line.

SKIP

writes a blank line after the last break line of a break located at the beginning of the report.

SUMMARIZE

includes a summary line as one of the break lines. A summary line at the beginning or end of a report contains values for statistics, ANALYSIS variables, or computed variables.

TITLE<n> <'title'>;

specifies a title. The argument n is a number from 1 to 10 that immediately follows the word TITLE, with no intervening blank, and it specifies the level of the TITLE. The text of each title must be enclosed in single or double quotation marks. The maximum title length depends on your operating environment and the value of the LINESIZE= system option. Refer to the SAS documentation for your operating environment for more information.

WHERE where-expression;

subsets the input data set by identifying certain conditions that each observation must meet before an observation is available for processing. Where-expression defines the condition. The condition is a valid arithmetic or logical expression that generally consists of a sequence of operands and operators.

Previous Page | Next Page | Top of Page