Statistical Graphics Using ODS This Document Is an Individual Chapter from SAS/STAT® 13.2 User’S Guide
Total Page:16
File Type:pdf, Size:1020Kb
SAS/STAT® 13.2 User’s Guide Statistical Graphics Using ODS This document is an individual chapter from SAS/STAT® 13.2 User’s Guide. The correct bibliographic citation for the complete manual is as follows: SAS Institute Inc. 2014. SAS/STAT® 13.2 User’s Guide. Cary, NC: SAS Institute Inc. Copyright © 2014, SAS Institute Inc., Cary, NC, USA All rights reserved. Produced in the United States of America. For a hard-copy book: No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute Inc. For a Web download or e-book: Your use of this publication shall be governed by the terms established by the vendor at the time you acquire this publication. The scanning, uploading, and distribution of this book via the Internet or any other means without the permission of the publisher is illegal and punishable by law. Please purchase only authorized electronic editions and do not participate in or encourage electronic piracy of copyrighted materials. Your support of others’ rights is appreciated. U.S. Government License Rights; Restricted Rights: The Software and its documentation is commercial computer software developed at private expense and is provided with RESTRICTED RIGHTS to the United States Government. Use, duplication or disclosure of the Software by the United States Government is subject to the license terms of this Agreement pursuant to, as applicable, FAR 12.212, DFAR 227.7202-1(a), DFAR 227.7202-3(a) and DFAR 227.7202-4 and, to the extent required under U.S. federal law, the minimum restricted rights as set out in FAR 52.227-19 (DEC 2007). If FAR 52.227-19 is applicable, this provision serves as notice under clause (c) thereof and no other notice is required to be affixed to the Software or documentation. The Government’s rights in Software and documentation shall be only those set forth in this Agreement. SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513. August 2014 SAS provides a complete selection of books and electronic products to help customers use SAS® software to its fullest potential. For more information about our offerings, visit support.sas.com/bookstore or call 1-800-727-3228. SAS® and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective companies. Gain Greater Insight into Your SAS® Software with SAS Books. Discover all that you need on your journey to knowledge and empowerment. support.sas.com/bookstore for additional books and resources. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective companies. © 2013 SAS Institute Inc. All rights reserved. S107969US.0613 Chapter 21 Statistical Graphics Using ODS Contents Introduction........................................... 586 Chapter Reading Guide ................................. 587 Assumptions about ODS Defaults in This Chapter................... 588 Getting Started with ODS Statistical Graphics......................... 588 Default Plots for Simple Linear Regression with PROC REG . 588 Survival Estimate Plot with PROC LIFETEST..................... 591 Contour and Surface Plots with PROC KDE ...................... 592 Contour Plots with PROC KRIGE2D.......................... 594 Partial Least Squares Plots with PROC PLS....................... 597 Box-Cox Transformation Plot with PROC TRANSREG . 599 LS-Means Diffogram with PROC GLIMMIX...................... 600 Principal Component Analysis Plots with PROC PRINCOMP . 601 Grouped Scatter Plot with PROC SGPLOT....................... 604 A Primer on ODS Statistical Graphics............................. 605 Enabling and Disabling ODS Graphics ......................... 606 Graph Styles....................................... 607 ODS Destinations .................................... 609 Accessing Individual Graphs............................... 611 Specifying the Size and Resolution of Graphs...................... 611 Modifying Your Graphs................................. 612 Procedures That Support ODS Graphics......................... 615 Procedures That Support ODS Graphics and Traditional Graphics . 615 Syntax.............................................. 616 ODS GRAPHICS Statement............................... 616 ODS Destination Statements............................... 619 PLOTS= Option..................................... 620 Selecting and Viewing Graphs................................. 622 Specifying an ODS Destination for Graphics...................... 622 Viewing Your Graphs in the SAS Windowing Environment . 624 Determining Graph Names and Labels ......................... 624 Selecting and Excluding Graphs............................. 626 Graphics Image Files...................................... 628 Image File Types..................................... 628 Scalable Vector Graphics ................................ 629 Naming Graphics Image Files.............................. 630 586 F Chapter 21: Statistical Graphics Using ODS Saving Graphics Image Files............................... 632 Creating Graphs in Multiple Destinations........................ 633 Graph Size and Resolution................................... 634 ODS Graphics Editor...................................... 636 Enabling the Creation of Editable Graphs........................ 636 Editing a Graph with the ODS Graphics Editor..................... 637 The Default Template Stores and the Template Search Path.................. 640 Styles.............................................. 641 An Overview of Styles.................................. 642 Style Elements and Attributes.............................. 644 Style Templates and Colors ............................... 645 Some Common Style Elements ............................. 646 Style Comparisons.................................... 652 Modifying the HTMLBLUE Style............................ 668 Style Template Modification Macro........................... 673 Creating an All-Color Style............................... 675 Changing the Default Markers and Lines........................ 677 Changing the Default Style ............................... 686 Statistical Graphics Procedures................................. 688 The SGPLOT Procedure................................. 688 The SGSCATTER Procedure .............................. 689 The SGPANEL Procedure................................ 690 The SGRENDER Procedure............................... 692 Examples of ODS Statistical Graphics............................. 698 Example 21.1: Creating Graphs with Tool Tips in HTML . 698 Example 21.2: Creating Graphs for a Presentation................... 699 Example 21.3: Creating Graphs in PostScript Files................... 700 Example 21.4: Displaying Graphs Using the DOCUMENT Procedure . 703 Example 21.5: Customizing the Style for Box Plots.................. 707 References........................................... 710 Introduction Effective graphics are indispensable for modern statistical analysis. They reveal patterns, differences, and uncertainty that are not readily apparent in tabular output. Graphics provoke questions that stimulate deeper investigation, and they add visual clarity and rich content to reports and presentations. In earlier SAS releases, creating graphs with statistical procedures typically required additional programming steps such as creating output data sets with the values to plot, modifying these data sets with a DATA step program, and using traditional SAS/GRAPH procedures to produce the plots. ODS Graphics eliminates the need for additional programming. ODS Graphics is an extension of ODS (the Output Delivery System). ODS manages procedure output and lets you display it in a variety of destinations, Chapter Reading Guide F 587 such as HTML and RTF. With ODS Graphics, statistical procedures produce graphs as automatically as they produce tables, and graphs are integrated with tables in the ODS output. ODS Graphics is available in procedures in SAS/STAT, Base SAS, SAS/ETS, SAS/QC, and other products (see the section “Procedures That Support ODS Graphics” on page 615). Note that ODS Graphics is automatically provided with Base SAS software. ODS Graphics might or might not be enabled by default depending on your operating system, whether you are in the SAS windowing environment, your registry, system options, and configuration file settings. For more information about default settings and enabling and disabling ODS Graphics, see the section “Enabling and Disabling ODS Graphics” on page 606. You can enable ODS Graphics with the following statement: ods graphics on; When ODS Graphics is enabled, procedures that support ODS Graphics create appropriate graphs, either by default or when you specify procedure options for requesting specific graphs. These options are documented in the “Syntax” section of each procedure chapter, and the “Details” section of each chapter provides an “ODS Graphics” subsection that lists the graphs that are available. Once ODS Graphics is enabled, it stays enabled for the duration of your SAS session unless you disable it. You can disable ODS Graphics with the following statement: ods