Previous Page | Next Page

Creating Detail and Summary Reports with the REPORT Procedure

Understanding How to Construct a Report


Using the Report Writing Tools

The REPORT procedure combines the features of PROC MEANS, PROC PRINT, and PROC TABULATE along with features of the DATA step report writing into a powerful report writing tool. PROC REPORT enables you to do the following:

There are three different ways that you can use PROC REPORT to construct reports:

The windowing environment requires minimal SAS programming skills and allows immediate, visual feedback as you develop the report. This section explains how you use the nonwindowing environment to create summary and detail reports.

Types of Reports

The REPORT procedure enables you to construct two types of reports:

detail report

contains one row for every observation that is selected for the report (see The Default Report When the Data Set Contains Character Values). Each of these rows is a detail row.

summary report

consolidates data so that each row represents multiple observations (see Grouping Multiple Observations in a Summary Report). Each of these rows is also called a detail row.

Both detail and summary reports can contain summary lines as well as detail rows. A summary line summarizes numerical data for a set of detail rows or for all detail rows. You can use PROC REPORT to provide both default summaries and customized summaries.


Laying Out a Report


Establishing the Layout

If you first decide on the layout of the report, then creating the report is easier. You need to determine the following:

Once you establish the layout of the report, use the COLUMN statement and DEFINE statement in the PROC REPORT step to construct the layout.

Constructing the Layout

The COLUMN statement lists the report items to include as columns of the report, describes the arrangement of the columns, and defines headers that span multiple columns. A report item is a data set variable, a calculated statistic, or a variable that you compute based on other items in the report.

The DEFINE statement defines the characteristics of an item in the report. These characteristics include how PROC REPORT uses an item in the report, the text of the column header, and the format to display the values.

You control much of a report's layout by the usages that you specify for variables in the DEFINE statements. The types of variable usages are:

ACROSS

creates a column for each value of an ACROSS variable.

ANALYSIS

computes a statistic from a numeric variable for all the observations represented by a cell of the report. The value of the variable depends on where it appears in the report. By default, PROC REPORT treats all numeric variables as ANALYSIS variables and computes the sum.

COMPUTED

computes a report item from variables that you define for the report. They are not in the input data set, and PROC REPORT does not add them to the input data set.

DISPLAY

displays a row for every observation in the input data set. By default, PROC REPORT treats all character variables as DISPLAY variables.

GROUP

consolidates into one row all of the observations from the data set that have a unique combination of the formatted values for all GROUP variables.

ORDER

specifies to order the rows for every observation in the input data set according to the ascending, formatted values of the ORDER variable.

The position and usage of each variable in the report determine the report's structure and content. For example, PROC REPORT orders the detail rows of the report according to the values of ORDER and GROUP variables (from left to right). Similarly, PROC REPORT orders columns for an ACROSS variable from top to bottom, according to the values of the variable. For a complete discussion of how PROC REPORT determines the layout of a report, see the Base SAS Procedures Guide.

Previous Page | Next Page | Top of Page