REPORT Procedure

Example 6: Displaying Multiple Statistics for One Variable

Features:
PROC REPORT statement options:
LS=
PS=

COLUMN statement: specifying statistics for stacked variables

DEFINE statement options:
FORMAT=
GROUP
ID
Data set: GROCERY
Format: $MGRFMT

Details

The report in this example displays six statistics for the sales for each manager's store. The output is too wide to fit all the columns on one page, so three of the statistics appear on the second page of the report. In order to make it easy to associate the statistics on the second page with their group, the report repeats the values of Manager and Sector on every page of the report.

Program

libname proclib
'SAS-library';
options fmtsearch=(proclib);
proc report data=grocery nowd headline headskip
            ls=66 ps=18;
column sector manager (Sum Min Max Range Mean Std),sales;
   define manager / group format=$mgrfmt. id;
   define sector / group format=$sctrfmt.;
   define sales / format=dollar11.2 ;
   title 'Sales Statistics for All Sectors';
run;

Program Description

Declare the PROCLIB library. The PROCLIB library is used to store user-created formats.
libname proclib
'SAS-library';
Specify the format search library.The SAS system option FMTSEARCH= adds the SAS library PROCLIB to the search path that is used to locate formats.
options fmtsearch=(proclib);
Specify the report options. The NOWD option runs PROC REPORT without the REPORT window and sends its output to the open output destinations. HEADLINE underlines all column headings and the spaces between them at the top of each page of the report. HEADSKIP writes a blank line beneath the underlining that HEADLINE writes. LS= sets the line size for the report to 66, and PS= sets the page size to 18.
proc report data=grocery nowd headline headskip
            ls=66 ps=18;
Specify the report columns. This COLUMN statement creates a column for Sector, Manager, and each of the six statistics that are associated with Sales.
column sector manager (Sum Min Max Range Mean Std),sales;
Define the group variables and the analysis variable. ID specifies that Manager is an ID variable. An ID variable and all columns to its left appear at the left of every page of a report. In this report, Sector and Manager are group variables. Each detail row of the report consolidates the information for all observations with the same values of the group variables. FORMAT= specifies the formats to use in the report.
   define manager / group format=$mgrfmt. id;
   define sector / group format=$sctrfmt.;
   define sales / format=dollar11.2 ;
Specify the title.
   title 'Sales Statistics for All Sectors';
run;

Output

Sales Statistics for All Sectors