Chapter 5 Enhancing Your Output with ODS ODS















- Slides: 15

Chapter 5: Enhancing Your Output with ODS § ODS (Output Delivery System) can simply be a way to save high-quality output to different files: − RTF files − PS (Postscript files) − PDF files − HTML files (be sure to look at the text’s example in 5. 5 ) − OUTPUT (SAS data sets) © Fall 2011 John Grego and the University of South Carolina 1

Enhancing Your Output with ODS uses style templates to enhance default formats (for those who want to do EVERYTHING in SAS—or those who need to). § It is also an effective means to control output printed to the OUTPUT window (LISTING files) or written to SAS data sets. § © Fall 2011 John Grego and the University of South Carolina 2

Why ODS? § We have already learned a couple menu-driven applications of ODS § Selecting Create HTML. . to save output in HTML format in Exercise 6. § Right-clicking on a graphics window and saving it as a PDF file § The second example is analogous to saving graphics in R

ODS vs menu-drive options § While menu-driven options are convenient, they do have shortcomings when: § Generating many graphics in a large program § Generating graphics in a DO loop—remember the Monitoring Well data in R? § Generating graphics in a MACRO § We need in-line commands to save output files as well

Creating an output file § The basic structure ODS PDF FILE=‘stat 540 of an ODS filename. pdf’; command can be quite simple (SAS graphics commands) RUN; ODS PDF CLOSE;

Output formats This basic syntax is commonly used for postscript, html, and rtf files as well § Note the similarity to the use of the pdf() and postscript() functions in R § In addition to saving filename. pdf, an attractive PDF window will open in SAS § 6

Saving multiple graphics § We can include multiple PROC steps inside the ODS commands and generate multiple graphs 7

Reset default output device § ODS HTML CLOSE; An additional precaution: turn off ODS PDF the default output FILE=‘z: stat device (and restore 540fname. pdf’; it when finished). . ODS PDF CLOSE; ODS HTML; 8

Selecting Output SAS PROC’s can produce many separate pieces of output; some more useful than others § We can use ODS SELECT to choose pieces to output § 9

ODS TRACE identifies output names for ODS SELECT § Use of ODS TRACE has been somewhat superceded by availability of ODS table names in SAS documentation for its PROC steps § We will review both methods § 10

ODS Trace output The “trace” is printed in the LOG window—and it is quite cryptic! § Once you get used to the naming convention, it’s not so bad § ODS TRACE ON; (SAS PROC statements) RUN; ODS TRACE OFF; 11

ODS OUTPUT can save multiple output files § Remember that these output data sets can look odd… § …but judicious use of IF can take care of that § 12

Saving Output (SAS PROC ODS OUTPUT can save name, statements) label, and path ODS output pieces name=your_out_ name § Using the name path=your_out_ acts as a grouping path; variable in our example RUN; § 13

Enhancing Output ODS HTML output can be enhanced with STYLE statements § These styles can be complex, but some simple improvements can be made § E. g. , PROC PRINT tables can be enhanced with STYLE statements (Class Exercise 9) § 14

Traffic-lighting PROC FORMAT can be used for “trafficlighting” cells in HTML output § Chapter 8 has an extensive new section on ODS graphics; some of the earlier sections discuss simple ways to enhance the usual line-plotter graphics from, e. g. , PROC UNIVARIATE § 15