The REPORT Procedure |
What Does the REPORT Procedure Do? |
The REPORT procedure combines features of the PRINT, MEANS, and TABULATE procedures with features of the DATA step in a single report-writing tool that can produce a variety of reports. You can use PROC REPORT in three ways:
in a nonwindowing environment. In this case, you submit a series of statements with the PROC REPORT statement, just as you do in other SAS procedures. You can submit these statements from the Program Editor with the NOWINDOWS option in the PROC REPORT statement, or you can run SAS in batch, noninteractive, or interactive line mode. (See the information about running SAS in SAS Language Reference: Concepts.)
in an interactive report window environment with a prompting facility that guides you as you build a report.
in an interactive report window environment without the prompting facility.
This documentation provides reference information about using PROC REPORT in a windowing or nonwindowing environment. For task-oriented documentation for the nonwindowing environment, see SAS Technical Report P-258, Using the REPORT Procedure in a Nonwindowing Environment, Release 6.07.
What Types of Reports Can PROC REPORT Produce? |
A detail report contains one row for every observation selected for the report. Each of these rows is a report row, a detail report row. A summary report consolidates data so that each row represents multiple observations. Each of these rows is also called a detail row, a summary report row.
Both detail and summary reports can contain summary report lines(break lines) as well as report rows. A summary line summarizes numerical data for a set of detail rows or for all detail rows. PROC REPORT provides both default and customized summaries. (See Using Break Lines.)
This overview illustrates the types of reports that PROC REPORT can produce. The statements that create the data sets and formats used in these reports are in Selecting Variables for a Report. The formats are stored in a permanent SAS library. See Examples: REPORT Procedure for more reports and for the statements that create them.
What Do the Various Types of Reports Look Like? |
The data set that these reports use contains one day's sales figures for eight stores in a chain of grocery stores.
A simple PROC REPORT step produces a report similar to one produced by a simple PROC PRINT step. Simple Detail Report with a Detail Row for Each Observation illustrates the simplest type of report that you can produce with PROC REPORT. The statements that produce the report follow. The data set and formats that the program uses are created in Selecting Variables for a Report. Although the WHERE and FORMAT statements are not essential, here they limit the amount of output and make the values easier to understand.
libname proclib 'SAS-library';
options nodate pageno=1 linesize=64 pagesize=60 fmtsearch=(proclib); proc report data=grocery nowd; where sector='se'; format sector $sctrfmt. manager $mgrfmt. dept $deptfmt. sales dollar10.2; run;
Simple Detail Report with a Detail Row for Each Observation
The report in the following figure uses the same observations as the above figure. However, the statements that produce this report
order the rows by the values of Manager and Department
create a default summary line for each value of Manager
create a customized summary line for the whole report. A customized summary lets you control the content and appearance of the summary information, but you must write additional PROC REPORT statements to create one.
For an explanation of the program that produces this report, see Ordering the Rows in a Report.
Ordered Detail Report with Default and Customized Summaries
The summary report in the following figure contains one row for each store in the northern sector. Each detail row represents four observations in the input data set, one observation for each department. Information about individual departments does not appear in this report. Instead, the value of Sales in each detail row is the sum of the values of Sales in all four departments. In addition to consolidating multiple observations into one row of the report, the statements that create this report
customize the text of the column headings
create default summary lines that total the sales for each sector of the city
create a customized summary line that totals the sales for both sectors.
For an explanation of the program that produces this report, see Consolidating Multiple Observations into One Row of a Report.
Summary Report with Default and Customized Summaries
The summary report in the following figure is similar to the above figure. The major difference is that it also includes information for individual departments. Each selected value of Department forms a column in the report. In addition, the statements that create this report
compute and display a variable that is not in the input data set
double-space the report
put blank lines in some of the column headings.
Summary Report with a Column for Each Value of a Variable
The customized report in the following figure shows each manager's store on a separate page. Only the first two pages appear here. The statements that create this report create
a customized heading for each page of the report
a computed variable (Profit) that is not in the input data set
a customized summary with text that is dependent on the total sales for that manager's store.
For an explanation of the program that produces this report, see Writing a Customized Summary on Each Page.
The report in the following figure uses customized style elements to control things like font faces, font sizes, and justification, as well as the width of the border of the table and the width of the spacing between cells. This report was created by using the HTML destination of the Output Delivery System (ODS) and the STYLE= option in several statements in the procedure.
For an explanation of the program that produces this report, see Specifying Style Elements for ODS Output in Multiple Statements. For information about ODS, see Output Delivery System.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.