Creating PDF Output with ODS

The ODS PDF Statement

To open, manage, or close the PDF destinations that produce PDF output, use the ODS PDF statement:
Syntax, ODS PDF statement:
ODS PDF <(<ID=>identifier)> <action>;
  • (<ID=>identifier) enables you to open multiple instances of the same destination at the same time. Each instance can have different options.
    • identifier can be numeric or can be a series of characters that begin with a letter or an underscore. Subsequent characters can include letters, underscores, and numerals.
  • action can be one of the following:
    • CLOSE action closes the destination and any files that are associated with it.
    • EXCLUDE exclusions| ALL | NONE action excludes one or more output objects from the destination.
      Note: The default is NONE. A destination must be open for this action to take effect.
    • SELECT selections| ALL | NONE action selects output objects for the specified destination.
      Note: The default is ALL. A destination must be open for this action to take effect.
    • SHOW action writes the current selection list or exclusion list for the destination to the SAS log.
      Note: If the selection or exclusion list is the default list (SELECT ALL), then SHOW also writes the entire selection or exclusion list. The destination must be open for this action to take effect.
In SAS Studio, the PDF destination is open by default. In SAS Studio, you must use the ODS PDF statement with at least one action or option. When you do this, it opens another instance of a PDF destination and creates PDF output.

The ODS Printer Family of Statements

The ODS PDF statement is part of the ODS printer family of statements. Statements in the printer family open the PCL, PDF, PRINTER, or PS destination, producing output that is suitable for a high-resolution printer. The ODS PCL, ODS PRINTER, and ODS PS statements are also members of the ODS printer family of statements.

Opening and Closing the PDF Destination

You can modify an open PDF destination with many ODS PDF options. However, the FILE= and SAS options perform the following actions on an open PDF destination:
  • close the open destination referred to in the ODS PDF statement
  • close any files associated with the open PDF destination
  • open a new instance of the PDF destination
Note: If you use one of these actions, you should explicitly close the destination yourself.

Working with the Table of Contents

The ODS PDF destination provides the following navigation tools:
  • The default table of contents (TOC), which is a clickable bookmark tree that is not printed.
    Figure 16.5 PDF Output Default Bookmark Tree
    PDF Output Default Bookmark Tree
  • A printable table of contents, which is generated using the CONTENTS=YES option in the ODS PDF FILE= statement. The output that is created this way is static and does not count toward the page count of the PDF file. The text “Table of Contents” is customizable using PROC TEMPLATE, and the text of each of the entries is customizable with the ODS PROCLABEL statement and CONTENTS= options in some of the PROC statements.
    Figure 16.6 PDF Output Default Table of Contents Page
    PDF Output Default Table of Contents Page
The text displayed by the nodes of each tool is controlled with the following:
  • the ODS PROCLABEL statement
  • the CONTENTS=, the DESCRIPTION=, and the OBJECTLABEL= options
  • the DOCUMENT destination and procedure
  • the TEMPLATE procedure

Example: Creating PDF Output Using the FILE= Option

This example opens an instance of the PDF destination to create PDF output. The FILE= option specifies the PDF filename.
ods html close;
ods pdf file="SamplePDF";
proc freq data=sashelp.cars;
  tables origin*type;
run;
ods pdf close;
Figure 16.7 PDF Output of FREQ Procedure
PDF Output of FREQ Procedure

Example: Creating a Printable Table of Contents

By default, ODS PDF does not create a printable table of contents, only a click-able bookmark tree. This example shows you how to create a printable table of contents.
ods html close;
title "Create a Table of Contents";
options nodate;
ods pdf file="MyDefaultToc.pdf" contents=yes bookmarklist=hide;
proc freq data=sashelp.cars;
  tables origin*type;
run;
proc print data=sashelp.cars (obs=15);
run;
ods pdf close;
ods html path="%qsysfunc(pathname(work))";
The ODS PDF statement uses the following options:
  • The FILE= option specifies the PDF filename.
  • The CONTENTS=YES option specifies that a table of contents is created.
  • The BOOKMARKLIST=HIDE option specifies that a bookmark tree is created, but hidden.
Figure 16.8 Printable Table of Contents for PDF Output
Printable Table of Contents for PDF Output

Changing the Appearance of PDF Output

Style Templates

You can change the appearance of your PDF output by specifying a style in the STYLE= option in the ODS PDF statement. The default style for PDF output is Pearl. Here are the style templates that are currently available:
  • FancyPrinter
  • FestivalPrinter
  • GrayscalePrinter
  • Journal
  • MeadowPrinter
  • MonoChromePrinter
  • Monospace
  • NormalPrinter
  • Pearl
  • Printer
  • Sapphire
  • SasDocPrinter
  • SeasidePrinter

Example: The STYLE= Option (FestivalPrinter Style)

In the following program, the STYLE= option applies the FestivalPrinter style to the output for the ODS PDF statement:
ods html close;
ods pdf file="SamplePDF" style=FestivalPrinter; 
proc freq data=sashelp.cars;
  tables origin*type;
run;
ods pdf close;
Figure 16.9 ODS PDF Output with the FestivalPrinter Style Applied
ODS PDF Output with the FestivalPrinter Style Applied
Last updated: August 23, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.63.38