INTRODUCTION TO THE SAS ANNOTATE FACILITY

Similar documents
It s Not All Relative: SAS/Graph Annotate Coordinate Systems

Annotate Dictionary CHAPTER 11

How to annotate graphics

Data Annotations in Clinical Trial Graphs Sudhir Singh, i3 Statprobe, Cary, NC

Creating Forest Plots Using SAS/GRAPH and the Annotate Facility

Using ANNOTATE MACROS as Shortcuts

Coders' Corner. Paper ABSTRACT GLOBAL STATEMENTS INTRODUCTION

Effective Forecast Visualization With SAS/GRAPH Samuel T. Croker, Lexington, SC

Create Flowcharts Using Annotate Facility. Priya Saradha & Gurubaran Veeravel

The GANNO Procedure. Overview CHAPTER 12

Controlling Titles. Purpose: This chapter demonstrates how to control various characteristics of the titles in your graphs.

Multiple Forest Plots and the SAS System

Data Driven Annotations: An Introduction to SAS/GRAPH s Annotate Facility

... WHERE. AnnotaI8 Data.S... XSYS & YSYS. Harie Annotate: How Not to Lose Your Head When Enhancing BAS/GRAPH output

USING SAS PROC GREPLAY WITH ANNOTATE DATA SETS FOR EFFECTIVE MULTI-PANEL GRAPHICS Walter T. Morgan, R. J. Reynolds Tobacco Company ABSTRACT

PharmaSUG Paper TT10 Creating a Customized Graph for Adverse Event Incidence and Duration Sanjiv Ramalingam, Octagon Research Solutions Inc.

Tips to Customize SAS/GRAPH... for Reluctant Beginners et al. Claudine Lougee, Dualenic, LLC, Glen Allen, VA

Tips for Producing Customized Graphs with SAS/GRAPH Software. Perry Watts, Fox Chase Cancer Center, Philadelphia, PA

The GSLIDE Procedure. Overview. About Text Slides CHAPTER 27

PharmaSUG 2012 Paper CC13

Custom Map Displays Created with SAS/GRAPH Procedures and the Annotate Facility Debra Miller, National Park Service, Denver, CO

Converting Annotate to ODS Graphics. Is It Possible?

THE IMPACT OF DATA VISUALIZATION IN A STUDY OF CHRONIC DISEASE

Put Your Data on the Map: Using the GEOCODE and GMAP Procedures to Create Bubble Maps in SAS

Innovative Graph for Comparing Central Tendencies and Spread at a Glance

Creating a Basic Chart in Excel 2007

Chapter 10 Working with Graphs and Charts

A SAS Macro to Generate Caterpillar Plots. Guochen Song, i3 Statprobe, Cary, NC

Presentation Quality Graphics with SAS/GRAPH

Figure 1. Paper Ring Charts. David Corliss, Marketing Associates, Bloomfield Hills, MI

The Plot Thickens from PLOT to GPLOT

SAS/GRAPH : Using the Annotate Facility

Microsoft Excel. Charts

Information Visualization

Using Annotate Datasets to Enhance Charts of Data with Confidence Intervals: Data-Driven Graphical Presentation

Chapter 13 Introduction to Graphics Using SAS/GRAPH (Self-Study)

Want Quick Results? An Introduction to SAS/GRAPH Software. Arthur L. Carpenter California Occidental Consultants

Using SAS/GRAPH Software to Analyze Student Study Habits. Bill Wallace Computing Services University of Saskatchewan

Taming the Box Plot. Sanjiv Ramalingam, Octagon Research Solutions, Inc., Wayne, PA

Pete Lund Looking Glass Analytics, Olympia, WA

A Generalized Procedure to Create SAS /Graph Error Bar Plots

Making Presentations More Fun with DATA Step Graphics Interface (DSGI) Hui-Ping Chen, Eli Lilly and Company, Indianapolis, Indiana

SAS/GRAPH Introduction. Winfried Jakob, SAS Administrator Canadian Institute for Health Information

SAS/GRAPH and ANNOTATE Facility More Than Just a Bunch of Labels and Lines

SparkLines Using SAS and JMP

Customized Flowcharts Using SAS Annotation Abhinav Srivastva, PaxVax Inc., Redwood City, CA

Displaying Multiple Graphs to Quickly Assess Patient Data Trends

Something for Nothing! Converting Plots from SAS/GRAPH to ODS Graphics

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

ODS LAYOUT is Like an Onion

Paper SIB-096. Richard A. DeVenezia, Independent Consultant, Remsen, NY

Splitting Axis Text. Splitting Text in Axis Tick Mark Values

Creating Maps in SAS/GRAPH

Excel 2013 Intermediate

Developing a Dashboard to Aid in Effective Project Management

SAS: Proc GPLOT. Computing for Research I. 01/26/2011 N. Baker

Using SAS Graphics Capabilities to Display Air Quality Data Debbie Miller, National Park Service, Denver, CO

SUGI 29 Posters. Paper A Group Scatter Plot with Clustering Xiaoli Hu, Wyeth Consumer Healthcare., Madison, NJ

Graphical Techniques for Displaying Multivariate Data

HOUR 12. Adding a Chart

Multiple Graphical and Tabular Reports on One Page, Multiple Ways to Do It Niraj J Pandya, CT, USA

ABSTRACT. The SAS/Graph Scatterplot Object. Introduction

Data Explore Matrix Quality Control by Exploring and Mining Data in Clinical Study

A Picture is worth 3000 words!! 3D Visualization using SAS Suhas R. Sanjee, Novartis Institutes for Biomedical Research, INC.

CHAPTER 1 Introduction to SAS/GRAPH Software

PharmaSUG 2013 CC26 Automating the Labeling of X- Axis Sanjiv Ramalingam, Vertex Pharmaceuticals, Inc., Cambridge, MA

Move =(+0,+5): Making SAS/GRAPH Work For You

Fly over, drill down, and explore

Fiqure 1. Graphics 229. NESUG '93 Proceedings

Introduction to SAS. I. Understanding the basics In this section, we introduce a few basic but very helpful commands.

Picturing Statistics Diana Suhr, University of Northern Colorado

Unit 1 Lesson 4 Representing Data. Copyright Houghton Mifflin Harcourt Publishing Company

A Plot & a Table per Page Times Hundreds in a Single PDF file

Tips and Tricks in Creating Graphs Using PROC GPLOT

PharmaSUG 2015 Paper PO03

ABC s of Graphs in Version 8 Caroline Bahler, Meridian Software, Inc.

An Introduction to the DATA Step Graphics Interface Earl Westerlund, Eastman Kodak Company, Rochester, NY

MANAGING SAS/GRAPH DISPLAYS WITH THE GREPLAY PROCEDURE. Perry Watts IMS Health

Top Award and First Place Best Presentation of Data Lan Tran-La. Scios Nova, Inc. BLOOD PRESSURE AND HEART RATE vs TIME

Microsoft Excel 2007

SAS Graph: Introduction to the World of Boxplots Brian Spruell, Constella Group LLC, Durham, NC

Information Visualization

Paper S Data Presentation 101: An Analyst s Perspective

The GTESTIT Procedure

* builds the RGB color string from the color. * reads the red, green; and blue values for. * constructs an ANNOTATE dataset by

A Juxtaposition of Tables and Graphs Using SAS /GRAPH Procedures

Wood Grain Image Textures

Reverse-engineer a Reference Curve: Capturing Tabular Data from Graphical Output Brian Fairfield-Carter, ICON Clinical Research, Redwood City, CA

Technology Assignment: Scatter Plots

Introduction to the workbook and spreadsheet

Quick. Efficient. Versatile. Graphing Software for Scientists and Engineers.

Posters 417. NESUG '92 Proceedings. usinq Annotate Data sets to Enhance Contour Graphics output. Shi Tao Yeh, Environmental Resources Kanaqement, ~nc.

Spreadsheet definition: Starting a New Excel Worksheet: Navigating Through an Excel Worksheet

SAS Graphs in Small Multiples Andrea Wainwright-Zimmerman, Capital One, Richmond, VA

ABSTRACT INTRODUCTION SESUG RV

Rafe M. J. Donahue, Ph.D. Associate Director, Statistics BioMimetic Therapeutics, Inc. Franklin, TN

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

Sixth Grade SOL Tracker Name:

How to Make an Impressive Map of the United States with SAS/Graph for Beginners Sharon Avrunin-Becker, Westat, Rockville, MD

A Stand-Alone SAS Annotate System for Figure Generation Brian Fairfield-Carter, PRA International, Victoria, BC

Transcription:

Improving Your Graphics Using SAS/GRAPH Annotate Facility David J. Pasta, Ovation Research Group, San Francisco, CA David Mink, Ovation Research Group, San Francisco, CA ABSTRACT Have you ever created a graph with SAS/GRAPH and really liked it except for one little thing? The Annotate facility in SAS/GRAPH allows you to enhance or change features of your plot or chart. This presentation introduces Annotate and provides practical examples to illustrate how to improve your graphs. You do not need to be an expert at SAS/GRAPH to use Annotate. Even though Annotate is an extremely powerful tool for creating entirely custom figures, with a few guidelines (and the Annotate macros) it can be easy to use for simpler tasks. In this presentation, we will explain the principles behind Annotate and give specific examples of some common uses: adding a label to a single point on a graph, re-labeling an axis, adding a custom box of text, and applying white out to unwanted text. You will learn basic building blocks of Annotate that can be applied to many different graph enhancement situations. INTRODUCTION This tutorial is intended for SAS programmers with a working knowledge of base SAS and at least some exposure to SAS/GRAPH. The concepts of the Annotate facility will be fully introduced, followed by some examples that even an Annotate veteran may find helpful. The Annotate facility in SAS/GRAPH is a very useful tool for enhancing or changing features of your graphical output. Often when creating graphs using SAS, you find one little part that you wish you could change or one little item you wish you could add that would make your output perfect. Annotate gives you the flexibility to add any drawing object or text, in any format or color, to any place on your graphical output. This flexibility is what makes Annotate such an important and useful tool to learn for anyone planning to create graphics with SAS. Using a data set provided in SAS/GRAPH documentation, this tutorial goes through some concrete examples of how to apply an Annotate solution to common graphing problems. Example 1 shows you how to place text next to a single point in a scatter plot and illustrates the importance of the co-ordinate systems. Example 2 addresses the problem of customizing a logarithmic axis. Example 3 illustrates some of the Annotate macros by showing you how to build a customized legend. Example 4 illustrates how to white out unwanted items in your graph output. The examples make the concepts of the Annotate facility in SAS/GRAPH more concrete. Much of the material here is taken from the SAS/GRAPH Reference Manual. INTRODUCTION TO THE SAS ANNOTATE FACILITY In order to use the Annotate facility of SAS/GRAPH, the first step is to create an Annotate data set. The Annotate data set is a specific SAS data set with specific variables that can be manipulated in ordinary ways. Each observation in the data set is a drawing command defined by the values placed in each of the specific variables. The next step is to tell SAS to execute the Annotate commands by including the following option in you SAS/GRAPH code: /ANNOTATE=<annotate file name> SAS/GRAPH interprets and executes the drawing commands along with the graph and creates output that has both included. You can even use PROC GANNO to produce output entirely from Annotate with no graph. The concept is straightforward; now let us look more closely at some of the details. ANNOTATE DATA SET VARIABLES An Annotate data set must contain variables with predefined names. Other variables can be present in the data set, but they will be ignored by the Annotate facility. The Annotate variables tell Annotate what to do, how to do it, or where to do it. Below is a table defining some of the important variables that will be used in our examples. For a complete list of Annotate variables, refer to the SAS/GRAPH documentation. 1

TABLE 1. ANNOTATE DATA SET VARIABLES VARIABLE DESCRIPTION FUNCTION Specifies the Annotate drawing action. Table 2 below gives a list of important functions. X The numeric horizontal coordinate. Y The numeric vertical coordinate. Z For three-dimensional graphs, specifies the coordinate for the 3 rd dimension. HSYS The type of units for the size (height) variable. XSYS The coordinate system for the X variable. YSYS The coordinate system for the Y variable. ZSYS The coordinate system for the Z variable (for three-dimensional graphs). ANGLE Angle of text label or start angle for a pie slice. COLOR Color of graphics item. LINE Line type of graphics item. POSITION Placement/alignment of text. ROTATE Angle of individual characters in a text string or the sweep of a pie slice. SIZE Size of the graphics item. Specific to the function. For example, size is the height of the character for a label function. STYLE Font/pattern of a graphics item. TEXT Text to use in a label, symbol, or comment. WHEN Determines if Annotate command is executed (B)efore or (A)fter the graph. FUNCTIONS The Annotate data set FUNCTION variable tells SAS what to do. The other variables all modify, specify, or locate the function. Below is a table listing some of the more important functions that will be used in our examples. For a complete list of Annotate functions, refer to the SAS/GRAPH documentation. TABLE 2. FUNCTIONS FUNCTION LABEL MOVE DRAW COMMENT POLY POLYCONT BAR SYMBOL PIE DESCRIPTION Draws text. Moves to a specific point. Draws a line from the current position to a specified position. As a documentation aid, allows you to insert a comment into the SAS Annotate file. Specifies the starting point of a polygon. Continues drawing the polygon. Draws a rectangle from the current position to a specified position Draws a symbol. Draws a pie slice, circle or arc. 2

COORDINATE SYSTEMS The Annotate facility recognizes three different drawing areas, each with two possible unit types and the ability to designate these unit types as relative or absolute. These 12 conditions are coded as 1-9, A, B, and C based on Figure 1 below. FIGURE 1. AREAS AND THEIR COORDINATE SYSTEMS The first of the three drawing areas is the Data Area which represents only the space within the graph axes. The second graph in the middle of figure 1 shows the Graphics Output Area which is the entire writable page of output. Finally, the bottom graph shows the Procedure Output Area or the area taken up by the graphic object. The Data Area can be referenced by percent or by the actual axis scale values. The Procedure Output and Graphics Output Areas can be referenced by percent or cell values. Each of these area-unit combinations can be referenced either absolutely in relation to the entire area or relatively in relation to the last drawn object. These three conditions are combined to determine the correct coordinate system code. Once you have determined the appropriate coordinate system for each of your dimensions, you put the coded value in the XSYS and YSYS variables (and ZSYS for three-dimensional graphs). Based on the coordinate system(s), you chose where you want your graphics item to go, and assign those coordinate values to X and Y (and Z for three-dimensional graphs). X is the horizontal axis value and Y is the vertical axis value (Z is the depth value). This process gives you complete flexibility about where you put graphics items and how you reference those locations. For example, say you wanted to place a label starting in the exact center of your page of output. You would select the Graphics Output Area and an absolute referenced percent unit. From figure 1 the code for this is '3'. The '3' is assigned to XSYS and YSYS so that when you give X and Y the value of 50 (for half way or 50 percent) the label begins there. 3

ANNOTATE MACROS At this point it may seem as though creating SAS Annotate data sets is a tedious task. SAS has made it easier to accomplish by providing a set of Annotate macros. Consider the following data step that creates an Annotate data set to draw a black line: data annotate_data_set1; length function style color $8; retain xsys ysys hsys '3'; function= move ; x=35; y=25; output; function= draw ; color=black; line=1; size=1; x=65; y=25; output; FIGURE 2. A BLACK LINE The Annotate data set created tells SAS to move to (35,25) and draw a black line to (65,25). This same object can be drawn more easily and more intuitively with the %line macro. Before any Annotate macros are used you must issue the %ANNOMAC macro call. This call tells SAS to include the Annotate macro library and makes the macros available for use. The following code illustrates how Annotate macros can perform the same task: %annomac; data annotate_data_set2; %dclanno; retain xsys ysys hsys '3'; %line(35,25,65,25,black,1,1); The declarations have been simplified to one macro call (%dclanno) and the assignment and output statements in the first data step have been simplified into another macro call (%line). Table 3 lists some important Annotate macros that correspond to functions and their parameters. 4

Table 3. ANNOTATE MACROS MACRO %DCLANNO %LABEL(x, y, text-string, color, angle, rotate, size, style, position) %MOVE(x, y) %DRAW(x, y, color, line, size) %COMMENT(text-string) %POLY(x, y, color, style, line) %POLYCONT(x, y, color) %BAR(x1, y1, x2, y2, color, line, style) %LINE(x1, y1, x2, y2, color, line, size) %PIEXY(angle, size) %CIRCLE(x, y, size, color) DESCRIPTION Declares the Annotate variables. Places a label of text. Moves to a location. Draws a line from the current location to the specified location. Allows an unexecuted comment to be inserted into the Annotate data set. Begins drawing a polygon. Continues drawing a polygon. Draws a bar. Draws a line. Draws a pie slice. Draws a circle. A LOOK AT OUR SAMPLE DATA Now that you have an understanding of the Annotate facility, it is time to present some concrete examples. We will use the GIRIS2 sample data taken from the SAS/GRAPH manual. GIRIS2 contains Fisher s (1936) physical measurements of 150 irises. Fisher recorded the species (Setosa, Versicolor, and Virginica), petal length, petal width, sepal length, and sepal width of each iris. The examples here will focus on petal width and petal length for all species. Below is a table of this raw data. 5

TABLE 4. FISHER S 1936 IRIS PETAL AND DATA OBS PETAL IN mm PETAL IN mm OBS PETAL IN mm PETAL IN mm OBS PETAL IN mm 1 14 2 51 14 3 101 13 2 2 56 22 52 16 2 102 15 2 3 46 15 53 49 18 103 57 23 4 56 24 54 19 2 104 43 13 5 51 15 55 16 2 105 61 19 6 14 3 56 12 2 106 42 15 7 51 23 57 56 14 107 15 2 8 45 15 58 56 21 108 13 3 9 48 18 59 11 1 109 49 20 10 10 2 60 12 2 110 40 10 11 46 14 61 19 4 111 63 18 12 51 16 62 44 14 112 58 18 13 52 20 63 48 18 113 15 1 14 39 11 64 14 2 114 47 15 15 55 18 65 14 2 115 44 13 16 51 19 66 45 15 116 15 2 17 59 23 67 41 10 117 41 13 18 17 5 68 16 4 118 49 15 19 45 13 69 14 2 119 47 12 20 54 23 70 45 15 120 43 13 21 67 22 71 35 10 121 30 11 22 47 16 72 15 4 122 41 13 23 57 25 73 14 2 123 58 22 24 66 21 74 61 23 124 54 21 25 45 17 75 56 24 125 13 4 26 38 11 76 51 19 126 14 3 27 52 23 77 42 13 127 61 25 28 47 14 78 58 16 128 51 20 29 45 15 79 15 4 129 47 14 30 40 13 80 15 1 130 36 13 31 16 2 81 59 21 131 49 15 32 51 18 82 55 18 132 53 19 33 38 11 83 48 18 133 55 21 34 50 19 84 56 18 134 40 13 35 53 23 85 33 10 135 16 2 36 14 2 86 42 13 136 14 1 37 14 1 87 42 12 137 13 3 38 45 15 88 14 2 138 50 20 39 64 20 89 15 2 139 17 3 40 13 2 90 70 23 140 15 3 41 57 21 91 50 15 141 40 13 42 16 6 92 17 4 142 44 14 43 40 12 93 46 13 143 48 14 44 13 2 94 39 14 144 17 2 45 67 20 95 45 16 145 15 4 46 49 18 96 15 2 146 15 2 47 16 2 97 14 2 147 51 24 48 44 12 98 35 10 148 50 17 49 33 10 99 37 10 149 60 25 50 60 18 100 39 12 150 15 2 PETAL IN mm 6

EXAMPLE 1: ADDING A LABEL TO A SINGLE POINT ON A GRAPH The first example uses the Fisher iris data to create a scatter plot. Observation 90 has a length of 70mm and a width of 23mm. We would like to label this one point as Longest. This can be done using Annotate. A standard GOPTIONS statement is assumed here and throughout the examples, but not shown. Consider the code to create the following plot. proc gplot data=sample.giris2; title "Iris Petal Width Versus Length for All Species"; axis1 order=0 to 80 by 10 minor=(number=1) label=(angle=90 ""); axis2 order=0 to 30 by 5 minor=(number=1) label=(""); symbol Interpol=none value="x" color=black height=2; plot petallen*petalwid / vaxis=axis1 haxis=axis2 noframe annotate=annotate_data_ex1; quit; FIGURE 3. ADDING A LABEL TO A SINGLE POINT ON A GRAPH 80 Iris Petal Width Versus Length for All Species 70 Longest 60 50 40 30 20 10 0 0 5 10 15 20 25 30 Notice the addition of the option, annotate=annotate_data_ex1; to the plot statement. This allows the plot to incorporate the Annotate instructions found in the Annotate data set. The following is the code that creates the Annotate data set called annotate_data_ex1 and would have to precede the plot above: data annotate_data_ex1; length function color $8; retain xsys ysys '2' hsys '3'; function='label'; color='black'; x=23+2; y=70+5; text='longest'; output; 7

TABLE 5. ANNOTATE_DATA_EX1 Obs function color xsys ysys hsys x y text 1 label black 2 2 3 25 75 Longest The coordinate system selected for the x axis and y axis is 2. This corresponds (see Figure 1) to the Data Area with absolute values. With this coordinate system you can use the actual values of the point of interest to place the label. In Example 1, X is set to the X value plus 2 and Y is set to the Y value plus 5. This gives the label an offset so it is not written over the X. Any of these points could be labeled in this manner and the power of Annotate should begin to emerge because you can see how simple it would be to assign X and Y values and perhaps even text based on variables in the data set itself. EXAMPLE 2: RELABELING AN AXIS Example 2 shows how you can customize an entire axis. The way SAS/GRAPH displays log-based scales is not as flexible as you may like. You may want to specify the tick marks and labels with no good way outside of using the Annotate facility. In our example, we have converted the width axis to a log-based scale and then we use Annotate to specify tick marks and labels at 2, 5, 10, 20, 50, and 100. FIGURE 4. RELABELING AN AXIS 80 Iris Log Petal Width Versus Length for All Species 70 60 50 40 30 20 10 0 8

The GPLOT SAS code is similar to Example 1 with the change in the definition of axis2, the horizontal width axis. The log base scale is defined and all tick marks and labels are removed. proc gplot data=sample.giris2; title "Iris Log Petal Width Versus Length for All Species"; axis1 order=0 to 80 by 10 minor=(number=1) label=(angle=90 ""); axis2 order=(1,10,100) minor=none major=none value=none logbase=e label=(" " j=c ""); symbol Interpol=none value="x" color=black height=2; plot petallen*petalwid / vaxis=axis1 haxis=axis2 noframe annotate=annotate_data_ex2; quit; The Annotate data set must be defined to replace the tick marks and labels we left off the GPLOT command. The tick marks are drawn using the data display area. We know where on the x axis we want the tick marks so we ll draw short lines there. Then, using the graphical display area we can explicitly add the labels below each tick mark. %annomac; data annotate_data_ex2; %dclanno; xsys='2'; ysys='2'; hsys='3'; **Draw the tick marks; %line(2,-1.1,2,1,black,1,.25); %line(5,-1.1,5,1,black,1,.25); %line(10,-1.1,10,1,black,1,.25); %line(20,-1.1,20,1,black,1,.25); %line(50,-1.1,50,1,black,1,.25); %line(100,-1.1,100,1,black,1,.25); **Tick Mark Labels; xsys='3'; ysys='3'; %label(23,5," 2 ",black,0,0,3,simplex,1); %label(42,5," 5 ",black,0,0,3,simplex,1); %label(55,5,"10 ",black,0,0,3,simplex,1); %label(69,5,"20 ",black,0,0,3,simplex,1); %label(87,5,"50 ",black,0,0,3,simplex,1); %label(100,5,"100",black,0,0,3,simplex,1); TABLE 6. ANNOTATE_DATA_EX2 Obs STYLE FUNCTION COLOR XSYS YSYS HSYS WHEN POSITION X Y LINE SIZE ANGLE ROTATE TEXT 1 MOVE black 2 2 3 B 5 2-1.1.... 2 DRAW black 2 2 3 B 5 2 1.0 1 0.25.. 3 MOVE black 2 2 3 B 5 5-1.1 1 0.25.. 4 DRAW black 2 2 3 B 5 5 1.0 1 0.25.. 5 MOVE black 2 2 3 B 5 10-1.1 1 0.25.. 6 DRAW black 2 2 3 B 5 10 1.0 1 0.25.. 7 MOVE black 2 2 3 B 5 20-1.1 1 0.25.. 8 DRAW black 2 2 3 B 5 20 1.0 1 0.25.. 9 MOVE black 2 2 3 B 5 50-1.1 1 0.25.. 10 DRAW black 2 2 3 B 5 50 1.0 1 0.25.. 11 MOVE black 2 2 3 B 5 100-1.1 1 0.25.. 12 DRAW black 2 2 3 B 5 100 1.0 1 0.25.. 13 simplex LABEL black 3 3 3 B 1 23 5.0 1 3.00 0 0 2 14 simplex LABEL black 3 3 3 B 1 42 5.0 1 3.00 0 0 5 15 simplex LABEL black 3 3 3 B 1 55 5.0 1 3.00 0 0 10 16 simplex LABEL black 3 3 3 B 1 69 5.0 1 3.00 0 0 20 17 simplex LABEL black 3 3 3 B 1 87 5.0 1 3.00 0 0 50 18 simplex LABEL black 3 3 3 B 1 100 5.0 1 3.00 0 0 100 Adding tick marks and labels in this manner give you a great deal of flexibility when using logarithmic scales. Any labeling scheme that meets your needs can be easily implemented. 9

EXAMPLE 3: ADDING A CUSTOM BOX OF TEXT Example 3 constructs a legend from scratch using the Annotate facility. Although SAS can create a legend for you in a two-dimensional graph, you may want the flexibility to customize the look of a legend. G3D three-dimensional plots do not have a legend option so Annotate is your only choice for adding that type of information. The Fisher Iris scatter plot will be used again with the legend drawn in the upper left of the graphics area. This example also shows how using a relative reference co-ordinate system allows you to keep a group of annotate objects together to potentially move them around at once. FIGURE 5. ADDING A CUSTOM BOX OF TEXT 80 Iris Petal Width Versus Length for All Species 70 60 LEGEND X - Petal Length v. Width 50 40 30 20 10 0 0 5 10 15 20 25 30 The GPLOT SAS code used to create the plot is the same as the code in Example 1, Fisher's iris petal length and width scatter plot. Please refer to example 1 for details; only the Annotate data set creation data step will be show here. %annomac; data annotate_data_ex3; %dclanno; length text $30.; xsys='9'; ysys='9'; hsys='3'; **Draw the initial legend box; %move(15,80); %draw(25,0,black,1,.5); %draw(0,-10,black,1,.5); %draw(-25,0,black,1,.5); %draw(0,10,black,1,.5); **Legend Text; %cntl2txt; function='label'; color='black'; x=10; y=-2; text='legend'; size=3; output; function='label'; color='black'; x=-1; y=-2; size=3; text='x - Petal Length v. Width'; output; 10

TABLE 7. ANNOTATE_DATA_EX3 Obs STYLE FUNCTION COLOR XSYS YSYS HSYS WHEN POSITION X Y text LINE SIZE 1 MOVE 9 9 3 B 5 15 80.. 2 DRAW black 9 9 3 B 5 25 0 1 0.5 3 DRAW black 9 9 3 B 5 0-10 1 0.5 4 DRAW black 9 9 3 B 5-25 0 1 0.5 5 DRAW black 9 9 3 B 5 0 10 1 0.5 6 CNTL2TXT black 9 9 3 B 5.. 1 0.5 7 LABEL black 9 9 3 B 5 10-2 LEGEND 1 3.0 8 LABEL black 9 9 3 B 5-1 -2 X - Petal Length v. Width 1 3.0 This simple legend is placed in the upper left hand corner of the graphics area. The rectangle is drawn with absolute coordinates and the text within the box is drawn relative to that box. Should you come back and want to move the legend only the rectangle coordinates need to be changed. The text referenced relatively will follow along. This allows you to create more complex objects as groups of Annotate basic objects and move them around as a group. You can see from this example the concept of creating a flexible customized legend. This is the only option for legends in G3D graphs. EXAMPLE 4: WHITING OUT UNWANTED TEXT The problem in example 4 is that of unwanted text and how to eliminate it. Suppose you want to add a vertical reference line to the Fisher Iris scatter plot representing the mean of all the lengths. In this data, the mean petal length is 37.75mm. This is a common requirement for many graphs, but can present a problem when labeling. We would like the reference line label to be along the y-axis with the tick mark labels, but it will conflict with the 40mm tick mark label. Since you want to keep the other labels and all the tick marks, the 40 is our only problem and must be eliminated. The Annotate facility allows you to create a rectangle the color of the background and the size of the unwanted label. Then a 37.75 can be added to label the reference line with no conflict. FIGURE 6. WHITING OUT UNWANTED TEXT 80 Iris Petal Width Versus Length for All Species With Mean Length 70 60 50 40 37.75 30 20 10 0 0 5 10 15 20 25 30 11

The SAS/GRAPH code to create the above scatter plot is as follows. Please note the addition of the VREF option on the plot statement to generate the vertical reference line. proc gplot data=sample.giris2; title "Iris Petal Width Versus Length for All Species With Mean Length"; axis1 order=0 to 80 by 10 minor=(number=1) label=(angle=90 ""); axis2 order=0 to 30 by 5 minor=(number=1) label=(""); symbol Interpol=none value="x" color=black height=2; plot petallen*petalwid / vaxis=axis1 haxis=axis2 vref=37.75 noframe annotate=annotate_data_ex4; quit; The data step that creates annotate_data_ex4 should precede the above GPLOT. Using graphics output area coordinates, the 40 tick mark label is located. A background color box is drawn using the %bar macro. Then the example adds to the Annotate data set the label for the reference line. %annomac; data annotate_data_ex4; %dclanno; xsys='3'; ysys='3'; hsys='3'; **White-Out Rectangle; when='a'; %bar(5,55,8.5,51,white,3,solid); **Reference Line Label; function='label'; color="black"; x=7; y=51.5; text='37.75'; size=3; style=""; output; TABLE 8. ANNOTATE_DATA_EX4 Obs STYLE FUNCTION COLOR XSYS YSYS HSYS WHEN POSITION X Y LINE SIZE text 1 MOVE white 3 3 3 A 5 5.0 55.0.. 2 solid BAR white 3 3 3 A 5 8.5 51.0 3 0 3 label black 3 3 3 A 5 7.0 51.5 3 3 37.75 Using the white out concept above, you can eliminate a wide variety of unwanted graph marks and items. CONCLUSION What we have presented here is a brief introduction to the Annotate facility with examples. Those who are interested in learning more are directed to the SAS/GRAPH Manuals where additional topics on the use of Annotate in GCHART, GMAPS, and G3D graphics are presented. You can also learn to draw circles, pies, and arcs. If you are a very interested reader, you may want to also explore the subtleties of how SAS keeps track of the locations and positions of graphics items and character strings. Annotate is a powerful flexible tool that will allow you to draw any text or object on any graphical output. Try these examples and others in the SAS/GRAPH manual and you will learn never to settle for a graph that is perfect except for one little thing. 12

REFERENCES SAS Institute Inc. 2004, SAS/GRAPH Software: Reference, Version 9, Cary, NC: SAS Institute Inc. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the authors at: David Pasta Ovation Research Group 120 Howard Street, Suite 600 San Francisco, CA 94105 (415) 371-2100 dpasta@ovation.org David Mink Ovation Research Group 120 Howard Street, Suite 600 San Francisco, CA 94105 (415) 371-2100 dmink@ovation.org SAS and SAS/GRAPH are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies. 13