208-25 LEGEND OPTIONS USING MULTIPLE PLOT STATEMENTS IN PROC GPLOT



Similar documents
OVERVIEW OF THE ENTERPRISE GUIDE INTERFACE

Let SAS Write Your SAS/GRAPH Programs for You Max Cherny, GlaxoSmithKline, Collegeville, PA

Tips and Tricks: Using SAS/GRAPH Effectively A. Darrell Massengill, SAS Institute, Cary, NC

Using SAS/GRAPH Software to Create Graphs on the Web Himesh Patel, SAS Institute Inc., Cary, NC Revised by David Caira, SAS Institute Inc.

Graphing in SAS Software

CC03 PRODUCING SIMPLE AND QUICK GRAPHS WITH PROC GPLOT

Forcing SAS/GRAPH Software to Meet My Statistical Needs: A Graphical Presentation of Odds Ratios

The Basics of Creating Graphs with SAS/GRAPH Software Jeff Cartier, SAS Institute Inc., Cary, NC

SAS/GRAPH 9.2 ODS Graphics Editor. User s Guide

Data Visualization with SAS/Graph

Multiple Graphs on One Page (Step-by-step approach) Yogesh Pande, Schering-Plough Corporation, Summit NJ

Box-and-Whisker Plots with The SAS System David Shannon, Amadeus Software Limited

Soma Ghosh, UnitedHealth Group, Minneapolis, MN

Using SAS to Create Graphs with Pop-up Functions Shiqun (Stan) Li, Minimax Information Services, NJ Wei Zhou, Lilly USA LLC, IN

Pop-Ups, Drill-Downs, and Animation Mike Zdeb, School of Public Health, Rensselaer, NY

containing Kendall correlations; and the OUTH = option will create a data set containing Hoeffding statistics.

Each function call carries out a single task associated with drawing the graph.

Histogram of Numeric Data Distribution from the UNIVARIATE Procedure

Export Customized Graphs Directly into Microsoft Word Using Dynamic Data Exchange

Microsoft Excel 2010 Charts and Graphs

Lecture 8 : Coordinate Geometry. The coordinate plane The points on a line can be referenced if we choose an origin and a unit of 20

Visualizing Key Performance Indicators using the GKPI Procedure Brian Varney, COMSYS, a Manpower Company, Portage, MI

Scientific Graphing in Excel 2010

Chapter 32 Histograms and Bar Charts. Chapter Table of Contents VARIABLES METHOD OUTPUT REFERENCES...474

Paper KEYWORDS PROC TRANSPOSE, PROC CORR, PROC MEANS, PROC GPLOT, Macro Language, Mean, Standard Deviation, Vertical Reference.

Gestation Period as a function of Lifespan

How To Manage A Project In Sas/Or Software

Excel Using Pivot Tables

Analyze the Stock Market Using the SAS System Luis Soriano, Qualex Consulting Services, Inc. Martinsville, VA

Lab: Graphing Activities TOTTEN

SAS Mapping: Technologies, Techniques, Tips and Tricks Darrell Massengill

Pro/ENGINEER Wildfire 4.0 Basic Design

Chapter 23: Drafting in Worksheet View

How to make a line graph using Excel 2007

Excel Using Pivot Tables

Scatter Plots with Error Bars

And Now, Presenting...

To draw a line. To create a construction line by specifying two points

Excel -- Creating Charts

Basic Understandings

Producing Structured Clinical Trial Reports Using SAS: A Company Solution

Grade level: secondary Subject: mathematics Time required: 45 to 90 minutes

5. Correlation. Open HeightWeight.sav. Take a moment to review the data file.

Plotting: Customizing the Graph

Examples of Data Representation using Tables, Graphs and Charts

SAS Mapping: Technologies, Techniques, Tips and Tricks

Scatter Chart. Segmented Bar Chart. Overlay Chart

Part 1: Background - Graphing

USE OF A SINGLE ELEMENT WATTMETER OR WATT TRANSDUCER ON A BALANCED THREE-PHASE THREE-WIRE LOAD WILL NOT WORK. HERE'S WHY.

Lab 11: Budgeting with Excel

WHO WE ARE. INTRODUCTION Throughout the year, numerous official data files and hard copy

Table Lookups: From IF-THEN to Key-Indexing

C:\Word\documentation\SAS\Class2\SASLevel2.doc 3/7/2013 Biostatistics Consulting Center

An Oracle White Paper December Cloud Candidate Selection Tool: Guiding Cloud Adoption

How to Graph Trigonometric Functions

MATLAB Workshop 14 - Plotting Data in MATLAB

Introduction to SAS /Graph Philip Mason, Wood Street Consulting, Wallingford, Oxfordshire, England

Using SAS s PROC GPLOT to plot data and lines

Creating Maps with SAS/GRAPH - Drill Downs, Pop-Ups, and Animation Mike Zdeb, University@Albany School of Public Health, Rensselaer, NY

Curve Fitting, Loglog Plots, and Semilog Plots 1

From Validating Clinical Trial Data Reporting with SAS. Full book available for purchase here.

Using PROC SGPLOT for Quick High Quality Graphs

Using PROC RANK and PROC UNIVARIATE to Rank or Decile Variables

CONSTRUCTING SINGLE-SUBJECT REVERSAL DESIGN GRAPHS USING MICROSOFT WORD : A COMPREHENSIVE TUTORIAL

Euler s Method and Functions

Embedded Special Characters Kiran Karidi, Mahipal Vanam, and Sridhar Dodlapati

Beginning Tutorials. BT005 MAPS MADE EASY USING SAS Mike Zdeb, School of Public Health

GUIDELINES FOR PREPARING POSTERS USING POWERPOINT PRESENTATION SOFTWARE

12-1 Representations of Three-Dimensional Figures

Guido s Guide to PROC FREQ A Tutorial for Beginners Using the SAS System Joseph J. Guido, University of Rochester Medical Center, Rochester, NY

Introduction to Microsoft Excel 2007/2010

PowerPoint Tables / Charts / Graphs

This activity will show you how to draw graphs of algebraic functions in Excel.

Multidimensional Data Visualization Tools

Updates to Graphing with Excel

(Least Squares Investigation)

From The Little SAS Book, Fifth Edition. Full book available for purchase here.

Getting Correct Results from PROC REG

Trigonometry Review with the Unit Circle: All the trig. you ll ever need to know in Calculus

CPM and GANTT: The Next Step in Multi-Project Management

Simulation Models for Business Planning and Economic Forecasting. Donald Erdman, SAS Institute Inc., Cary, NC

A. Test the hypothesis: The older you are, the more money you earn. Plot the data on the scatter plot below, choosing appropriate scales and labels.

Microsoft Excel 2010 Tutorial

PLOTTING DATA AND INTERPRETING GRAPHS

Scatterplots: Basics, enhancements, problems and solutions Peter L. Flom, Peter Flom Consulting, New York, NY

Advanced Programming with LEGO NXT MindStorms

Vector Notation: AB represents the vector from point A to point B on a graph. The vector can be computed by B A.

Create Charts in Excel

u = [ 2 4 5] has one row with three components (a 3 v = [2 4 5] has three rows separated by semicolons (a 3 w = 2:5 generates the row vector w = [ 2 3

Microsoft Excel 2010 Part 3: Advanced Excel

Transcription:

Paper 28-25 LEGEND OPTIONS USING MULTIPLE PLOT STATEMENTS IN PROC GPLOT Julie W. Pepe, University of Central Florida, Orlando, FL ABSTRACT A graph with both left and right vertical axes is easy to construct using SAS/GRAPH PROC GPLOT with multiple plot statements. Producing a correct legend requires some additional coding. Options for creating the legend are provided in this paper. Using the LEGEND statement requires an extraneous plot be hidden, thus providing information for the legend. This option is useful if you can hide a symbol within a symbol (i.e., dashed line and solid line or circle and dot). Another option is to use the FOOTNOTE statement to simulate a legend. For this option to work, symbols used in the graph must be reproduced in the footnote legend. INTRODUCTION Producing a graph with multiple plot statements using PROC GPLOT can cause the LEGEND option to print an incomplete list. Three options are given for creating a complete legend when using multiple plot statements and the OVERLAY option. The first option is to create an extra plot grouping which will complete the legend. Another option is to use symbols that can be added to the FOOTNOTE statement; this will appear as the legend. The final option, which is not a great solution, is to produce the correct graph with no legend and then paste a correct legend from an incorrect graph. The specific examples in this paper use variables Year (YEAR), Observed Count (OBS), Expected Count (EST), Temperature Adjusted Count (TEMP) and Water Level (WLEV). The expected counts and water levels are shown as joined symbols (polylines). Observed and expected counts are shown as symbols only. METHOD Option A Hidden symbol Two of the plotting pairs (displayed using different symbols) on the first plot statement must be identical in order to produce a correct legend. For this example, one of the symbols is a solid line and the other a dashed line. When the completed graph is viewed the solid line conceals the duplicate dashed line. The dashed line that is seen in the graph is actually from the second plot statement. The plot statements look like: PLOT EST*YEAR=1 OBS*YEAR=2 TEMP*YEAR=3 EST*YEAR=4 / OVERLAY HAXIS=AXIS1 VAXIS=AXIS2 LEGEND=LEGEND1; PLOT2 WLEV*YEAR=5 / HAXIS=AXIS1 VAXIS=AXIS3; Note: Symbol 1 diamonds joined by solid line Symbol 2 dot Symbol 3 circle Symbol 4 dashed line Symbol 5 dashed line Creating the legend is a simple matter of specifying the correct labels. The dashed line shown in the legend is actually produced due to the hidden line but is labeled with the variable name in the second plot statement. The legend statement specifies variable labels as well as positioning the legend. LEGEND1 LABEL=(POSITION=(BOTTOM RIGHT)) VALUE=( PREDICTED OBSERVED TEMPERATURE ADJ. WATER LEVEL ); Plot A shows the graph produced from this coding structure. Option B Footnote It is difficult to reproduce the exact look of the generated legend but a footnote can be set to show symbols and corresponding variable names. Use symbols that are obtainable on the keyboard, do not use dot or circle, as these are not readily available. The FOOTNOTE statement can be structured in the desired format. Because the legend will be incomplete, the graph is produced using the NOLEGEND option. The following code shows the necessary statements. PLOT EST*YEAR OBS*YEAR TEMP*YEAR/ OVERLAY NOLEGEND HAXIS=AXIS1 VAXIS=AXIS2; PLOT2 WLEV*YEAR / NOLEGEND HAXIS=AXIS1 VAXIS=AXIS3; The symbols used can be defined in the symbol statements or assigned as macro variables and referenced in the symbol and footnote statements. Peter Ruzsa at SAS Institute provided the original code for this option; I have modified the code for use in this paper. Plot B demonstrates the output form for this type of coding. Option C Paste The last resort option is to produce the correct graph with two plot statements using the NOLEGEND option. Then produce a graph with one plot statement and LEGEND option. Use this correct legend and paste it on to the graph. Plot C first shows the correct graph and then the incorrect graph with correct legend. Pasting can be

accomplished the old fashioned way or with Proc Annotate. Email: pepe@mail.ucf.edu Web: http://pegasus.cc.ucf.edu/~pepe The SAS code for options A and B is given in Appendices A and B. SUMMARY Options for producing a correct legend when overlaying plots within a graph are to either hide a symbol that can appear in the legend or use a footnote to produce a legend. In the first option, a dashed line (hidden) and solid line represent the same plotting pair. Symbol pairs where one masks the other must be used. Another option is to use the FOOTNOTE statement in place of the standard legend. The appearance can be structured as desired but must utilize available keyboard symbols. 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. REFERENCES SAS Institute Inc., SAS/GRAPH Software: Usage, Version 6, First Edition, Cary, NC: SAS Institute Inc., 1991. SAS Institute Inc., SAS/GRAPH Software: Reference, Version 6, First Edition, Volume 1, Cary, NC: SAS Institute Inc., 199. SAS Institute Inc., SAS/GRAPH Software: Reference, Version 6, First Edition, Volume 2, Cary, NC: SAS Institute Inc., 199. 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. ACKNOWLEDGMENTS The author wishes to thank Arnold Brunell, Florida Game and Freshwater Fish Commission, Alligator Management Program for the consulting project that resulted in this paper and Peter Ruzsa, SAS Institute Inc. for contributing the footnote option. CONTACT INFORMATION Contact the author at: Julie Pepe University of Central Florida Department of Statistics Post Office Box 16237 Orlando, Florida 32816-237 Work Phone: (47) 823-5532 Fax: (47) 823-5669

Plot A Hidden Symbol Code 77 76 75 74 Water Level 73 Plot B Year Predicted Observed Temperature Adj. Water Level PLOT 72 77 76 75 74 Water Level 73 YEAR 72

Plot C Paste code 77 76 75 74 Water Level 73 Year 72 paste code Year Predicted Observed Water Temp. Adj. Water Level PLOT

Appendix A /************** Hidden Symbol plot****************/ /****** create data set ******/ options linesize=8 pagesize=6; data option; input year wlev obs est temp; cards; 92 77 24 113 78 93 72 266 143 75 94 75 279 164 76 95 76 253 188 76 ; /****** plot options ******/ filename grapha 'plota.cgm'; goptions device=cgmwp gsflen=8 gsfmode=replace gsfname=grapha htext=1.; title1 ' PLOT A '; title2 'Hidden Symbol Code'; symbol1 interpol=join value=diamond height=1; symbol2 interpol=none value=dot height=1; symbol3 interpol=none value=circle height=1; symbol4 interpol=join line=2 value=none height=1; symbol5 interpol=join line=2 value=none height=1; axis1 minor=none label=(justify=center 'Year'); axis2 minor=(height=1) major=(height=1.5) label=(angle=9 rotate= ''); axis3 minor=(height=1) major=(height=1.5) label=(justify=center angle=-9 rotate= 'Water Level'); legend1 label=(position=(bottom right)) value=('predicted' 'Observed' 'Temperature Adj.' 'Water Level'); proc gplot data=option; plot est*year=1 obs*year=2 temp*year=3 est*year=4 /overlay haxis=axis1 vaxis=axis2 legend=legend1; plot2 wlev*year=5 / haxis=axis1 vaxis=axis3 nolegend; run; /**************** End of code ****************************/

******************** SUGI 9-7-99 ************ ********* Footnote Code ****** ************ Data set ********* options = linesize =8 pagesize = 6; data stuff; input year wlev obs est temp; cards; 92 77 24 113 78 93 72 266 143 75 94 75 279 164 76 95 76 253 188 76 ; /***********************plot code********/ filename graphb 'plotbb.cgm'; goptions device=cgmwp gsflen=8 gsfmode=replace gsfname=graphb htext=1.; title1 'PLOT B '; title1 'Footnote Code '; %let sym1 ='*'; %let sym2 ='+'; %let sym3 ='#'; %let sym4 ='$'; proc gplot; axis1 minor=none label=(justify=center 'YEAR'); axis2 minor=(height=1) major=(height=1.5) label=(angle=9 rotate= '' ); axis3 minor=(height=1) major=(height=1.5) label=(justify=center angle=-9 rotate= 'Water Level' ); plot est * year obs * year temp * year / overlay nolegend haxis=axis1 vaxis=axis2; plot2 wlev * year / nolegend haxis=axis1 vaxis=axis3; symbol1 f=swiss interpol=join value=&sym1; symbol2 f=swiss value=&sym2; symbol3 f=swiss value=&sym3; symbol4 f=swiss interpol=join line=2 value=&sym4; footnote f=swiss j=right 'Estimated Count =' "&sym1" f=swiss j=right 'Observed Count =' "&sym2"; footnote2 f=swiss j=right 'Temp. Adj. Count =' "&sym3" f=swiss j=right 'Water Level =' "&sym4"; run;