Study guide
9.2 Generating PDF, HTML, & RTF Output Destinations
SAS Certified Specialist: Base Programming Using SAS 9.4 A00-231
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: SAS Base Programming Exam Overview
1.1 A00-231 Exam Format, Scoring & Test-Day Logistics 1.2 Official Content Areas, Weights & Study Plan
2 Chapter 2: Accessing & Creating SAS Data Structures
2.1 SAS Environment, Syntax Rules, & Data Step Basics 2.2 SAS Data Libraries & the LIBNAME Statement 2.3 Investigating Libraries with PROC CONTENTS & PROC DATASETS 2.4 Importing Delimited & Excel Data with PROC IMPORT 2.5 Raw Data Ingestion with INFILE and INPUT Statements
3 Chapter 3: Managing & Combining SAS Data Sets
3.1 Reading SAS Data Sets with the SET Statement 3.2 Combining Data Sets: Concatenating & Interleaving 3.3 Match-Merging with BY Statements & FIRST./LAST. Processing 3.4 Controlling Data Output & Variable Selection (KEEP, DROP, RENAME, OBS=)
4 Chapter 4: Data Transformation & Conditional Logic
4.1 Creating & Modifying Variables with Assignment Statements 4.2 Modifying Variable Attributes with LENGTH, LABEL, FORMAT & RENAME= 4.3 Conditional Processing: IF-THEN/ELSE Statements & WHERE Subsetting 4.4 Accumulating Totals & Subtotals (RETAIN & Sum Statement) 4.5 Processing Data Iteratively with DO Loops
5 Chapter 5: SAS Functions & Data Type Conversions
5.1 Character Functions for String Manipulation 5.2 Numeric & Mathematical Functions 5.3 Working with SAS Dates, Times, & Intervals 5.4 Reading & Displaying Dates with Informats and Formats 5.5 Explicit & Implicit Data Type Conversions (INPUT & PUT)
6 Chapter 6: Restructuring Data & Program Maintenance
6.1 SAS Array Processing for Multi-Variable Transformations 6.2 Sorting Data Sets with PROC SORT 6.3 Restructuring Data Sets with PROC TRANSPOSE 6.4 Creating & Applying Custom Formats with PROC FORMAT 6.5 Simplifying Programs with Macro Variables (%LET)
7 Chapter 7: Error Handling & Debugging SAS Programs
7.1 SAS Log Analysis & Diagnostic Messages 7.2 Syntax vs. Logic Errors & Phasing 7.3 Debugging Techniques with _ERROR_, _N_, & PUT Statements 7.4 Identifying Logic Errors with the PUTLOG Statement 7.5 Handling Missing Values & Preventing Calculation Propagations
8 Chapter 8: Summary & Detail Data Reporting
8.1 Detail Reporting with PROC PRINT 8.2 Descriptive Statistics with PROC MEANS & PROC SUMMARY 8.3 Frequency & Categorical Analysis with PROC FREQ 8.4 Screening Extreme & Missing Values with PROC UNIVARIATE 8.5 Custom Tabular Reports with PROC REPORT & PROC TABULATE
9 Chapter 9: ODS Output Delivery & Data Export
9.1 Output Delivery System (ODS) Architecture Basics 9.2 Generating PDF, HTML, & RTF Output Destinations 9.3 Exporting Reports to Excel with ODS EXCEL & XLSX 9.4 Generating CSV, PowerPoint & Other ODS Destinations 9.5 Customizing ODS Titles, Footnotes, & Global Options 9.6 Exporting SAS Data Sets with PROC EXPORT & the XLSX Engine
9.2 Generating PDF, HTML, & RTF Output Destinations
Key Takeaways Explain This Topic AI
Opening an ODS destination requires ODS <destination> FILE='file-path'; and must be closed with ODS <destination> CLOSE; to release file locks.
Multiple ODS destinations (e.g., HTML, PDF, RTF) can be open simultaneously, receiving procedure output in parallel without re-executing steps.
The STYLE= option on an ODS destination statement applies built-in or custom CSS/printer style templates (e.g., STYLE=HTMLBlue, STYLE=Sapphire, STYLE=Journal).
Closing the LISTING destination (ODS LISTING CLOSE;) prevents SAS from generating redundant monospaced text output, improving execution performance.
HTML destination sub-options such as BODY=, FRAME=, CONTENTS=, and PAGE= allow the creation of multi-frame web reports with automated tables of contents.
Last updated: August 2026
9.2 Generating PDF, HTML, & RTF Output Destinations
The true power of ODS lies in its ability to format raw procedure output into polished, publication-ready documents. By opening specific ODS destinations , SAS programmers can generate web pages (HTML), printable vector documents (PDF), and editable word-processor documents (RTF) simultaneously from a single execution of SAS code.
ODS Destination Statement Lifecycle
Managing ODS destinations follows a strict syntax lifecycle:
Open the destination and specify the target output file path and options.
Execute SAS DATA steps or procedure steps (e.g., PROC PRINT , PROC REPORT , PROC MEANS ).
Close the destination to flush output buffers, write file headers/footers, and release OS file locks. +-------------------------------------------------------------+
- | 1. Open Destination: ODS <destination> FILE='path' <opts>; |
- +-------------------------------------------------------------+
- |
- v
- +-------------------------------------------------------------+
- | 2. Execute SAS Steps: PROC PRINT / PROC REPORT / PROC MEANS |
- +-------------------------------------------------------------+
- |
- v
- +-------------------------------------------------------------+
- | 3. Close Destination: ODS <destination> CLOSE; |
- +-------------------------------------------------------------+
- Basic Syntax Pattern ODS <destination> FILE = "file-specification" <options>;
/* SAS Code Generating Reports */
ODS <destination> CLOSE;
Warning
If you omit the ODS <destination> CLOSE; statement, the output file remains locked by the SAS session. You will be unable to open, move, or edit the resulting file in external applications like Adobe Acrobat or Microsoft Word until the destination is closed or the SAS session terminates.
Generating Core Destinations: HTML, PDF, and RTF
SAS supports numerous file destinations. The three core document destinations tested on the SAS Base Programming exam are HTML , PDF , and RTF .
1. The ODS HTML Destination
The ODS HTML destination produces web-compatible HTML files. In modern SAS interfaces (such as SAS Studio or Enterprise Guide), HTML is often the default viewing destination. ods html file="C:\reports\sales_summary.html" style=HTMLBlue;
- proc print data=sashelp.class;
- run;
- ods html close;
- Advanced ODS HTML Options (Multi-Frame Reports)
ODS HTML allows you to split output into a frame structure with an automated table of contents: ods html body = "C:\reports\body.html"
- contents = "C:\reports\toc.html"
- frame = "C:\reports\main_frame.html"
- style = Meadow;
- proc report data=sashelp.shoes;
- column Region Sales Inventory;
- define Region / group;
- run;
ods html close;
ODS HTML File Option Purpose
BODY= Specifies the HTML file containing the actual procedure tables and graphics.
CONTENTS= Specifies the HTML file containing a hyperlinked Table of Contents (TOC).
FRAME= Specifies an HTML frame file that integrates the contents and body into a split window.
PAGE= Specifies an HTML file containing links to each new page of output.
2. The ODS PDF Destination
The ODS PDF destination produces high-resolution, vector-based PDF documents ideal for printing, archiving, and distribution. ods pdf file="C:\reports\annual_report.pdf"
- style=Pearl
- pdftoc=1
- dpi=300;
- title "Company Sales Analysis";
- proc means data=sashelp.prdsale sum;
- class Country;
- var Actual Predict;
- run;
- ods pdf close;
- Key ODS PDF Options
FILE = "filename.pdf" : Required path for PDF output.
PDFTOC = 1 | 2 : Enables bookmark outline trees in PDF readers up to specified expansion depth.
UNIFORM : Maintains consistent column widths across multiple pages or tables.
STARTPAGE = YES | NO | NOW : Controls page breaking behavior between procedures.
3. The ODS RTF Destination
The ODS RTF destination produces Rich Text Format documents that can be opened and edited natively in Microsoft Word. ods rtf file="C:\reports\clinical_trial.rtf" style=Journal;
- proc freq data=sashelp.heart;
- tables Status * Sex / chisq;
- run;
- ods rtf close;
- Applying Styles with the STYLE= Option
Every ODS destination uses a visual style template to determine fonts, background colors, cell padding, table borders, and line spacing. SAS includes dozens of built-in styles.
You apply a style using the STYLE= option on the ODS destination opening statement: ODS PDF FILE="report.pdf" STYLE=Sapphire;
Commonly Tested Built-in SAS Styles
Style Name Intended Use / Visual Characteristics
HTMLBlue Default modern blue-themed style for web and screen presentation.
Pearl Clean, high-contrast light theme popular for PDF reports.
Sapphire Deep blue accents with crisp table borders.
Journal Black-and-white, minimal monospaced/serif style designed for academic publications.
Printer High-contrast grayscale optimized for black-and-white paper printing.
- Managing Default Destinations & Performance Optimization
- Default SAS Environment Behavior
Depending on how SAS is executed, certain destinations are opened automatically at session startup:
SAS Windowing Environment (Display Manager) : LISTING and/or HTML may be open by default.
SAS Studio : ODS HTML5 destination is managed automatically by the application container.
Batch Mode : ODS LISTING is active by default.
Disabling the LISTING Destination for Efficiency
The legacy LISTING destination formats output as traditional fixed-width text files. When generating large reports in HTML or PDF, leaving LISTING open causes SAS to format output twice (once for LISTING and once for PDF/HTML), consuming unnecessary CPU and memory.
It is standard SAS best practice to close LISTING before executing production report pipelines: /* 1. Turn off LISTING to conserve CPU resources */
ods listing close;
- /* 2. Open desired production destinations */
- ods pdf file="C:\reports\large_report.pdf" style=Pearl;
- ods html file="C:\reports\large_report.html" style=HTMLBlue;
- /* 3. Run production reporting procedures */
- proc report data=sashelp.demographics;
- run;
- /* 4. Close production destinations */
- ods pdf close;
- ods html close;
- /* 5. Re-open LISTING for normal interactive work */
- ods listing;
- Destination Management Syntax Comparison
- Action ODS Command Syntax
- Open PDF with custom style ODS PDF FILE='output.pdf' STYLE=Pearl;
- Close PDF destination ODS PDF CLOSE;
- Close LISTING destination ODS LISTING CLOSE;
- Re-open LISTING destination ODS LISTING;
- Query open destinations ODS DESTALL; / Check SAS Log