REPORT Procedure

Example 8: Condensing a Report into Multiple Panels

Features:
PROC REPORT statement options:
FORMCHAR=
HEADLINE
LS=
PANELS=
PS=
PSPACE=

BREAK statement options: SKIP

Other features:

SAS system option FORMCHAR=

Data set: GROCERY
Formats: $MGRFMT

$DEPTFMT

Details

The report in this example does the following:
  • uses panels to condense a two-page report to one page. Panels compactly present information for long, narrow reports by placing multiple rows of information side by side.
  • uses a default summary to place a blank line after the last row for each manager.
  • changes the default underlining character for the duration of this PROC REPORT step.

Program

libname proclib
'SAS-library';
options fmtsearch=(proclib);
proc report data=grocery nowd headline
            formchar(2)='~'
            panels=99 pspace=6
            ls=64 ps=18;
   column manager department sales;
   define manager / order
                    order=formatted
                    format=$mgrfmt.;
   define department / order
                 order=internal
                 format=$deptfmt.;
   define sales / format=dollar7.2;
                  
   break after manager / skip;
   where sector='nw' or sector='sw';
   title 'Sales for the Western 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 panel of the report. FORMCHAR= sets the value of the second formatting character (the one that HEADLINE uses) to the tilde (~). Therefore, the tilde underlines the column headings in the output. HEADSKIP writes a blank line beneath the underlining that HEADLINE writes. LS= sets the line size for the report to 64, and PS= sets the page size to 18. PANELS= creates a multipanel report. Specifying PANELS=99 ensures that PROC REPORT fits as many panels as possible on one page. PSPACE=6 places six spaces between panels.
proc report data=grocery nowd headline
            formchar(2)='~'
            panels=99 pspace=6
            ls=64 ps=18;
Specify the report columns. The report contains a column for Manager, Department, and Sales.
   column manager department sales;
Define the sort order and analysis columns. The values of all variables with the ORDER option in the DEFINE statement determine the order of the rows in the report. In this report, PROC REPORT arranges the rows first by the value of Manager (because it is the first variable in the COLUMN statement) and then, within each value of Manager, by the values of Department. The ORDER= option specifies the sort order for a variable. This report arranges the values of Manager by their formatted values and arranges the values of Department by their internal values (np1, np2, p1, and p2). FORMAT= specifies the formats to use in the report.
   define manager / order
                    order=formatted
                    format=$mgrfmt.;
   define department / order
                 order=internal
                 format=$deptfmt.;
   define sales / format=dollar7.2;
                  
Produce a report summary. This BREAK statement produces a default summary after the last row for each manager. Because SKIP is the only option in the BREAK statement, each break consists of only a blank line.
   break after manager / skip;
Select the observations to process. The WHERE statement selects for the report only the observations for stores in the northwest or southwest sector.
   where sector='nw' or sector='sw';
Specify the title.
   title 'Sales for the Western Sectors';
run;

Output

Sales for the Western Sectors