REPORT Procedure

Example 15: Specifying Style Elements for ODS Output in the PROC REPORT Statement

Features:

STYLE= option in the PROC REPORT statement

Other features:

ODS PDF statement

ODS RTF statement

Data set: GROCERY
Formats: $MGRFMT

$DEPTFMT

Details

This example creates HTML, PDF, and RTF files and sets the style elements for each location in the report in the PROC REPORT statement.

Program

libname proclib
'SAS-library';
options fmtsearch=(proclib);
ods pdf file='external-PDF-file';
ods rtf file='external-RTF-file';
proc report data=grocery nowd headline headskip
style(report)=[cellspacing=5 borderwidth=10 bordercolor=blue]
style(header)=[color=yellow
               fontstyle=italic fontsize=6]
style(column)=[color=moderate brown
               fontfamily=helvetica fontsize=4]
style(lines)=[color=white backgroundcolor=black
              fontstyle=italic fontweight=bold fontsize=5]
style(summary)=[color=cx3e3d73 backgroundcolor=cxaeadd9
                fontfamily=helvetica fontsize=3 textalign=r];
   column manager department sales;
   define manager / order
                    order=formatted
                    format=$mgrfmt.
                    'Manager';
   define department / order
                       order=internal
                       format=$deptfmt.
                       'Department';
   break after manager / summarize;
   compute after manager;
      line 'Subtotal for ' manager $mgrfmt. 'is '
            sales.sum dollar7.2 '.';
   endcomp;
   compute after;
       line 'Total for all departments is: '
            sales.sum dollar7.2 '.';
   endcomp;
   where sector='se';
   title 'Sales for the Southeast Sector';
run;
ods pdf close;
ods rtf close;

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 ODS output filenames. By opening multiple ODS destinations, you can produce multiple output files in a single execution. HTML output is produced by default. The ODS PDF statement produces output in Portable Document Format (PDF). The ODS RTF statement produces output in Rich Text Format (RTF). The output from PROC REPORT goes to each of these files.
ods pdf file='external-PDF-file';
ods rtf file='external-RTF-file';
Specify the report options. The NOWD option runs PROC REPORT without the REPORT window. In this case, SAS writes the output to the traditional procedure output, the HTML body file, and the RTF and PDF files.
proc report data=grocery nowd headline headskip
Specify the style attributes for the report. This STYLE= option sets the style element for the structural part of the report. Because no style element is specified, PROC REPORT uses all the style attributes of the default style element for this location except for CELLSPACING=, BORDERWIDTH=, and BORDERCOLOR=.
style(report)=[cellspacing=5 borderwidth=10 bordercolor=blue]
Specify the style attributes for the column headings. This STYLE= option sets the style element for all column headings. Because no style element is specified, PROC REPORT uses all the style attributes of the default style element for this location except for the ones that are specified here.
style(header)=[color=yellow
               fontstyle=italic fontsize=6]
Specify the style attributes for the report columns. This STYLE= option sets the style element for all the cells in all the columns. Because no style element is specified, PROC REPORT uses all the style attributes of the default style element for this location except for the ones that are specified here.
style(column)=[color=moderate brown
               fontfamily=helvetica fontsize=4]
Specify the style attributes for the compute block lines. This STYLE= option sets the style element for all the LINE statements in all compute blocks. Because no style element is specified, PROC REPORT uses all the style attributes of the default style element for this location except for the ones that are specified here.
style(lines)=[color=white backgroundcolor=black
              fontstyle=italic fontweight=bold fontsize=5]
Specify the style attributes for report summaries. This STYLE= option sets the style element for all the default summary lines. Because no style element is specified, PROC REPORT uses all the style attributes of the default style element for this location except for the ones that are specified here.
style(summary)=[color=cx3e3d73 backgroundcolor=cxaeadd9
                fontfamily=helvetica fontsize=3 textalign=r];
Specify the report columns. The report contains columns for Manager, Department, and Sales.
   column manager department sales;
Define the sort order variables. In this report Manager and Department are order variables. PROC REPORT arranges the rows first by the value of Manager (because it is the first variable in the COLUMN statement), then by the value of Department. For Manager, ORDER= specifies that values of Manager are arranged according to their formatted values; similarly, for Department, ORDER= specifies that values of Department are arranged according to their internal values. FORMAT= specifies the format to use for each variable. Text in quotation marks specifies the column headings.
   define manager / order
                    order=formatted
                    format=$mgrfmt.
                    'Manager';
   define department / order
                       order=internal
                       format=$deptfmt.
                       'Department';
Produce a report summary. The BREAK statement produces a default summary after the last row for each manager. SUMMARIZE writes the values of Sales (the only analysis or computed variable in the report) in the summary line. PROC REPORT sums the values of Sales for each manager because Sales is an analysis variable that is used to calculate the Sum statistic.
   break after manager / summarize;
Produce a customized summary. The COMPUTE statement begins a compute block that produces a customized summary after each value of Manager. The LINE statement places the quoted text and the values of Manager and Sales.sum (with the formats $MGRFMT. and DOLLAR7.2) in the summary. An ENDCOMP statement must end the compute block.
   compute after manager;
      line 'Subtotal for ' manager $mgrfmt. 'is '
            sales.sum dollar7.2 '.';
   endcomp;
Produce a customized end-of-report summary. This COMPUTE statement begins a compute block that executes at the end of the report. The LINE statement writes the quoted text and the value of Sales.sum (with the DOLLAR7.2 format). An ENDCOMP statement must end the compute block.
   compute after;
       line 'Total for all departments is: '
            sales.sum dollar7.2 '.';
   endcomp;
Select the observations to process. The WHERE statement selects for the report only the observations for stores in the southeast sector.
   where sector='se';
Specify the title.
   title 'Sales for the Southeast Sector';
run;
Close the ODS destinations.
ods pdf close;
ods rtf close;

HTML Output

Sales for the Southeast Sector

PDF Output

Sales for the Southeast Sector

RTF Output

Sales for the Southeast Sector