How to annotate graphics

Similar documents
INTRODUCTION TO THE SAS ANNOTATE FACILITY

Annotate Dictionary CHAPTER 11

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

Creating Forest Plots Using SAS/GRAPH and the Annotate Facility

Coders' Corner. Paper ABSTRACT GLOBAL STATEMENTS INTRODUCTION

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

Using ANNOTATE MACROS as Shortcuts

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

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

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

Multiple Forest Plots and the SAS System

The GSLIDE Procedure. Overview. About Text Slides CHAPTER 27

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

PharmaSUG 2012 Paper CC13

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

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

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

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

Creating Population Tree Charts (Using SAS/GRAPH Software) Robert E. Allison, Jr. and Dr. Moon W. Suh College of Textiles, N. C.

Create Flowcharts Using Annotate Facility. Priya Saradha & Gurubaran Veeravel

Innovative Graph for Comparing Central Tendencies and Spread at a Glance

The GANNO Procedure. Overview CHAPTER 12

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

Graphical Techniques for Displaying Multivariate Data

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

THE IMPACT OF DATA VISUALIZATION IN A STUDY OF CHRONIC DISEASE

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

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

The Plot Thickens from PLOT to GPLOT

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

The Evolution of a SAS/GRAPH Application Jenine Eason, AutoTrader.com, Atlanta, GA

Converting Annotate to ODS Graphics. Is It Possible?

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

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

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

Arthur L. Carpenter California Occidental Consultants

Pete Lund Looking Glass Analytics, Olympia, WA

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

Creating Maps in SAS/GRAPH

SparkLines Using SAS and JMP

Picturing Statistics Diana Suhr, University of Northern Colorado

FILLPATTERNS in SGPLOT Graphs Pankhil Shah, PPD, Morrisville, NC

Tips and Tricks in Creating Graphs Using PROC GPLOT

ABC Macro and Performance Chart with Benchmarks Annotation

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

Creating Complex Graphics for Survival Analyses with the SAS System

IMPROVING A GRAPH USING PROC GPLOT AND THE GOPTIONS STATEMENT

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

A Generalized Procedure to Create SAS /Graph Error Bar Plots

Anticipating User Issues with Macros

Desktop Studio: Charts. Version: 7.3

Focusing healthcare quality improvement dollars: Using SAS

Coders' Corner. Scaling Mount GCHART: Using a MACRO to Dynamically Reset the Scale Nina L. Werner, Dean Health Plan, Inc., Madison, WI.

Desktop Studio: Charts

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

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

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

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

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

ODS LAYOUT is Like an Onion

Fly over, drill down, and explore

SAS/GRAPH : Using the Annotate Facility

Presentation Quality Graphics with SAS/GRAPH

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

Information Visualization

Paper Time Contour Plots. David J. Corliss, Wayne State University / Physics and Astronomy

CHAPTER 1 Introduction to SAS/GRAPH Software

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

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

Working with Charts Stratum.Viewer 6

Splitting Axis Text. Splitting Text in Axis Tick Mark Values

And Now, Presenting... Presentation Quality Forecast Visualization with SAS/GRAPH Samuel T. Croker, Independent Consultant, Lexington, SC

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

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

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

Using SAS to Create Custom Healthcare Graphics Barbara B. Okerson, WellPoint, Richmond, VA

Time Contour Plots. David J. Corliss Magnify Analytic Solutions, Detroit, MI

Using SAS Graphics to Explore Behavioral Health Cost Risk Barbara B. Okerson, HMC, Richmond, VA

The Basics of Map Creation with SAS/GRAPH. Mike Zdeb School of Public Health Rensselaer, NY

Developing a Dashboard to Aid in Effective Project Management

PharmaSUG 2015 Paper PO03

Six Cool Things You Can Do In Display Manager Jenine Milum, Charlotte, NC Wachovia Bank

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

Interactive Graphs from the SAS System

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

Chapter 10 Working with Graphs and Charts

The GIMPORT Procedure

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

Creating a Basic Chart in Excel 2007

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

Using SAS/GRAPH Software to Create Graphs on The Web Himesh Patel, SAS Institute Inc., Cary, NC

Week 05 Class Activities

ABSTRACT INTRODUCTION SESUG RV

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

- Figure 1 :~!!~'!~,~!!~ MANAGEMENT GRAPHICS IN A QUALITY ASSURANCE ENVIRONMENT. Shirley J. McLelland. SAS Code used to produce the graph,

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

SAS CLINICAL SYLLABUS. DURATION: - 60 Hours

Displaying Multiple Graphs to Quickly Assess Patient Data Trends

Paper S Data Presentation 101: An Analyst s Perspective

Transcription:

Paper TU05 How to annotate graphics Sandrine STEPIEN, Quintiles, Strasbourg, France ABSTRACT Graphs can be annotated using different functions that add graphics elements to the output. Amongst other things, the Annotate facility enables you to label points (plots), bars (horizontal and vertical bar charts), or to generate custom graphics. All information regarding the Annotate is contained in a data set called the Annotate data set that follows a specific structure. To build this data set of graphics commands, values can be assigned either explicitly with data step or implicitly with Annotate macros. A SAS/GRAPH procedure can be then submitted to produce the graphics output (Annotate option). In clinical studies, the Annotate facility can be used to: Label and distinguish two types of curves on the same graph (e.g. diastolic and systolic blood pressure), Give the sample size at each point on a graph presenting mean over time, Create shifted vertical lines to show the variability of data (standard error, standard error of the mean, confidence interval ) on a plot of means. 1

INTRODUCTION Programming graphs using SAS/GRAPH is not really easy and user-friendly but with some experience and thanks to the annotate facilities it is possible to program some types of graphs which don t seem possible. The Annotate facility gives a large number of possibilities to customize your graph. Graphics elements as lines, text, and polygons can be added inside your graph in order to enhance graphics information or to make it clearer. This paper will give you some technical clues and some concrete examples in order to give you an overview of how to annotate graphics. ANNOTATE DATA SET The Annotate data set contains all information concerning the graphics elements to be added to the graphics output. In an Annotate data set, each observation represents a command to draw a graphics element or to perform an action. The Annotate variables have predefined names. The Annotate facility looks only for variables with those names. Other variables can be present, but they are ignored. There are three types of variables: An action variable tells what to do. The only action variable is FUNCTION, which specifies what graphics element to draw or what action to take. Positioning variables tells where to do it. The positioning variables specify the point at which to draw the graphics element. Attribute variables tells how to do it. The attribute variables specify the characteristics of the graphics element (for example, color, size, line style, text font, position). Summary of Annotate Variables Task Group Variable Description Variable that defines an action Positioning variables that determine coordinate values Positioning variables that contain internal coordinates FUNCTION GROUP MIDPOINT SUBGROUP X Y Z XC YC XLAST, YLAST XLSTT, YLSTT specifies a drawing or programming action; Summary of Graphics Tasks Performed by Annotate Functions describes these actions. uses the value of the GCHART GROUP= option in place of X or Y uses the value of the GCHART MIDPOINT= option in place of X or Y uses the value of the GCHART SUBGROUP= option in place of X or Y specifies a numeric horizontal coordinate specifies a numeric vertical coordinate specifies a numeric third dimensional coordinate; used with G3D procedure only specifies a horizontal character coordinate; only used with data coordinate systems 1, 2, 7, 8 specifies a vertical character coordinate; only used with data coordinate systems 1, 2, 7, 8 contain the X and Y coordinates of the last nontext function contain the X and Y coordinates of the last text function Positioning variables that HSYS specifies type of units for the SIZE variable 2

specify coordinate systems XSYS YSYS ZSYS specifies coordinate system for X or XC coordinates specifies coordinate system for Y or YC coordinates specifies coordinate system for Z coordinate (G3D procedure only) Attribute variables ANGLE angle of text label or starting angle of a pie slice CBORDER CBOX COLOR LINE POSITION ROTATE SIZE STYLE TEXT WHEN colored border around text or symbol colored box behind text or symbol color of a graphics primitive line type to use in drawing or special control over pies and bars placement and alignment for text strings angle at which to place individual characters in a text string or the delta angle (sweep) of a pie slice size of an aspect of a graphics primitive; depends on FUNCTION variable (for TEXT, height of characters; for PIE, pie slice radius; for DRAW, line thickness; and so on) font or pattern for a graphics element, depends on the FUNCTION variable text to use in a label, symbol, or comment whether a graphics element is drawn before or after procedure graphics output Web variable HTML specifies link information for a drill-down graph FUNCTION VARIABLE The different actions that can be performed on a graphic are the following: Annotate functions Action LABEL Draw text MOVE Move to the specified point (X,Y) DRAW Draw a line from the current (X,Y) position POINT Draw a point Draw a rectangle from the current (X,Y) position; optionally fill BAR with a pattern There are also other functions ( FRAME, PIE, POLY, POLYCONT, SYMBOL ). For more details please check http://v8doc.sas.com/sashtml/gref/zaboutds.htm#znctable. 3

COORDINATE SYSTEM VARIABLES The first action to perform before creating the annotate actions is to define the data coordinate system for the Annotate. It determines how coordinates will be interpreted depending on: the area where annotate elements will be inserted. It could be data, graphics output area, procedure output area, the unit for the coordinate system (values, %, cells) the placement (absolute or relative). The data coordinate system is coded by the following variables XSYS, YSYS, ZSYS (for 3-D graphs), HSYS (specifies the type of units for the SIZE variable). To add information inside the graph itself (area delimited by the graph axis), and to use plotted value coordinates to draw annotate elements, the method to be used is: Area defined as Data Unit defined as Values Placement defined as Absolute Which corresponds to XSYS= 2 and YSYS= 2. Areas and Their Coordinate Systems PhUSE 2006 POSITIONING VARIABLES The positioning variables used to locate graphics elements have to be chosen according to the type of graph you want to annotate. See the table below: Positioning variables Action X Specifies a numeric horizontal coordinate Y Specifies a numeric vertical coordinate Specifies a numeric third dimensional coordinate, used with Z the G3D procedure only Specifies a horizontal character coordinate; only used with XC data coordinate systems 1, 2, 7, 8 Specifies a vertical character coordinate; only used with data YC coordinate systems 1, 2, 7, 8 GROUP MIDPOINT SUBGROUP To annotate output from the GCHART procedure. Use these variables to specify coordinates for horizontal or vertical bar charts 4

ATTRIBUTE VARIABLES They determine how graphics elements will be output. For example, the code which defines the position of the label with regards to the coordinates of the point is useful information. Position codes are given in the figure below. Color, font, style have also to be defined if required by the function variable. Information can be found in the SAS online doc. 5

ANNOTATE MACROS A set of Annotate macros is provided in the SAS sample library. This is the implicit way of creating Annotate data sets and it can be used within a SAS DATA step to simplify the process of creating Annotate observations. With a macro, functions and variable values are specified and assigned in one step without having to write explicit variable assignment statements. Macro calls and assignment statements can be mixed in the same DATA step. The ANNOMAC macro must be run before any other Annotate macros are used in a SAS session. This enables you to access macro facilities to create your Annotate data set. A message in the SAS log shows how to get help for using the macros. Tasks with Annotate Macros If you want to... assign values of (XLSTT,YLSTT) to (XLAST,YLAST) begin drawing a polygon continue drawing a polygon copy (XLAST,YLAST) to (XLSTT,YLSTT) declare all variables draw a bar draw a circle draw a frame draw a line from (XLAST,YLAST) to (XLSTT,YLSTT) draw a line from previous point draw a line draw a pie slice or arc draw a rectangle draw text exchange the values of (XLAST,YLAST) and (XLSTT,YLSTT) move to a point near a pie slice move to a point without drawing Use this macro... %TXT2CNTL; %POLY(x, y, color, style, line); %POLYCONT(x, y, color); %CNTL2TXT; %DCLANNO; %BAR(x1, y1, x2, y2, color, line, style); %CIRCLE(x, y, size, color); %FRAME(color, line, size, style); %DRAW2TXT(color, line, size); %DRAW(x, y, color, line, size); %LINE(x1, y1, x2, y2, color, line, size); %SLICE(x, y, angle, rotate, size, color, style, line); %RECT(x 1,y 1,x 2,y 2, color, line, size); %LABEL(x, y, text, color, angle, rotate, size, style, position); %SWAP; %PIEXY(angle, size); %MOVE(x, y); 6

put values into a stack retrieve values from a stack scale and move input scale input set the coordinate system for the observation set when to draw an observation write a comment to the data set %PUSH; %POP; %SCALET(ptx, pty, x0, y0, x1, y1, x0, vy0, vx1, vy1); %SCALE(ptx, pty, x0, y0, x1, y1, x0, vy0, vx1, vy1); %SYSTEM(xsys, ysys, hsys); %SEQUENCE(when); %COMMENT(text); EXAMPLE 1 This example shows how to get help for the Annotate macros THE PROGRAM %HELPANO(ALL); %annomac; THE LOG MESSAGE For further information on ANNOTATE macros, enter, %HELPANO(macroname), (for specific macros) %HELPANO(ALL), (for information on all macros) or %HELPANO (for a list of macro names) 1791 %HELPANO(ALL); ANNOTATE MACROS The ANNOTATE macros are designed to lessen the burden of coding ANNOTATE observations. They are to be used within the confines of a SAS data step. Each of the available macros is described briefly below. Consult the ANNOTATE documentation for command parameters. BAR(x1, y1, x2, y2, color, bar_type, pattern) draws fillable rectangle with opposing corners at (x1, y1) and (x2, y2) valid bar_type values are : 0 draw all edges 1 vertical adjust 2 horizontal adjust 3 draw no edges color of asterisk(*) denotes previous assignment CIRCLE(x1, y1, rad, color) draws empty circle with center at (x1, y1) 1792 %annomac; *** ANNOTATE macros are now available *** 7

EXAMPLE 2 Example 2 shows you how to define the Annotate data set. When you use the SAS DATA step with assignment statements, each statement provides a value for an annotate variable. After assigning all the variable values for an observation, the OUTPUT statement has to be added to write the observation to the data set. It is easy to compare assignment statements with the Annotate macro calls that simplify the program. The MPRINT option gives you the details in the log of the explicit variable statements corresponding to the Annotate macros. THE PROGRAM data test; *declare variables; ******************; length function style color $8 text $50; *coordinate system using absolute % for the whole graph area; ************************************************************; retain hsys xsys ysys '3'; *create observation to draw the title; *************************************; function='label'; X=50;Y=90; position='5'; /*equal to X=23;Y=90;position='6';*/ text='sample Annotate Graphics'; style='zapfbi'; color='black'; size=6; OUTPUT; *create observations to draw the line below the title; *****************************************************; function='move'; X=23;Y=83; OUTPUT; function='draw'; X=78;Y=83; size=.5; color='black'; line=1; OUTPUT; *create graphics element using the Annotate macros; **************************************************; %annomac; %bar(5,5,50,50, brown, 0, r2); %circle(55,55,25,brown); %label(90,35,"phuse 2006",brown,90,0,10,zapfb,2); proc ganno annotate=test; quit; 8

THE ANNOTATE DATA SET func.# Style color text hsys/xsys/ysys X Y Pos* size line Angle rotate LABEL zapfbi black Sample Annotate Graphics 3 3 3 50 90 5 6.0... MOVE 3 3 3 23 83.... DRAW 3 3 3 78 83 0.5 1.. MOVE brown 3 3 3 5 5.. BAR r2 brown 3 3 3 50 50 0.0 0.. PIE EMPTY brown 3 3 3 55 55 25.0 0 0 360 LABEL zapfb brown phuse 2006 3 3 3 90 35 2 10.0 90 0 # function variable * position variable THE GRAPHICS OUTPUT EXAMPLE 3 You can add text anywhere in the graphics output to identify some points or add some information in order to make your graphics clearer. Here is an example of labeling curves of blood pressure when systolic and diastolic BP are on the same graph. Coordinates for the text have been chosen knowing that diastolic blood pressures are lower than systolic blood pressures. THE PROGRAM *enter descriptive statistics data; *---------------------------------; data mean; length bp $9; input trt time dbp sbp; cards; 1 0.5 88 138 1 1 89 131 1 2 87 130 1 3 88 128 1 4 86 126 1 6 84 127 1 8 83 124 9

1 10 80 123 1 12 83 127 2 0.5 81 124 2 1 82 123 2 2 80 120 2 3 80 122 2 4 78 124 2 6 82 120 2 8 80 120 2 10 79 122 2 12 76 120 ; PhUSE 2006 *create min and max values to annotate/label curves below or above the line curves; *---------------------------------------------------------------------------------; proc sql noprint; create table MIN as select min(dbp) as Y,max(time) as X from mean; create table MAX as select max(sbp) as Y,max(time) as X from mean; select min(dbp-10) into:minval from mean; select max(sbp+10) into:maxval from mean; quit; *create the annotate data set using DATA STEP; *--------------------------------------------; data ANNO1; length function style color $8 text $50; set MIN(in=min) MAX(in=max); *coordinate system; *******************; XSYS='2'; YSYS='2'; *add text on the graph area; ***************************; if min then do; function='label'; text='diastolic Blood Pressure'; position='4'; *(right align); style='zapfbi'; color='black'; size=1.5; end; if max then do; function='label'; text='systolic Blood Pressure'; position='4'; style='zapfbi'; color='black'; size=1.5; end; proc format; value TRT 1='Treatment X' 2='Treatment Y'; *generate the graph; *------------------; goptions reset=all display cback=white ftext=simplex ftitle=swiss colors=(black) 10

gunit=pct ctext=black htext=3 htitle=2; PhUSE 2006 axis1 offset=(5,5) label=(h=3 j=r "time point (hours)" ) value=(h=3); axis2 offset=(2,2) label=(h=4 angle=90 "Blood Pressure (mmhg)") value=(h=3) order=(&minval to &maxval by 10); axis3 offset=(5,5) label=none value=none major=none minor=none order=(&minval to &maxval by 10); legend1 label=(h=3 'treatement:') position=(top center inside) mode=protect value=(h=3 j=left) across=1; symbol1 i=join value=none line=2 color=olive width=4 h=2; symbol2 i=join value=none line=1 color=gold width=4 h=2; symbol3 i=join value=none line=2 color=olive width=4 h=2; symbol4 i=join value=none line=1 color=gold width=4 h=2; title;footnote; title1 j=c h=4 "Figure X: Annotated plot of mean"; proc gplot data=mean gout=graf; plot DBP*time=trt/ vaxis=axis2 haxis=axis1 legend=legend1 annotate=anno1; plot2 SBP*time=trt/ vaxis=axis3 haxis=axis1 nolegend; format trt trt.; quit; THE GRAPHICS OUTPUT 11

EXAMPLE 4 Bars/lines representing the variability of data could be added using Annotate. This example will show you how to create a plot of mean +/- SEM with shifted bar to avoid overlapping. THE PROGRAM *enter descriptive statistics data; *---------------------------------; data mean; input trt time dbp sem n; cards; 1 0.5 88 4 10 1 1 89 6 9 1 2 87 4 12 1 3 88 7 10 1 4 86 5 10 1 6 84 6 11 1 8 83 8 15 1 10 80 4 8 1 12 83 5 8 2 0.5 81 3 13 2 1 82 7 10 2 2 80 5 11 2 3 80 7 12 2 4 78 5 13 2 6 82 4 10 2 8 80 8 10 2 10 79 6 9 2 12 76 4 8 ; proc sql noprint; select min(dbp-sem-5) into:minval from mean; select max(dbp+sem+5) into:maxval from mean; quit; *create the annotate data set using Annotate macros; *--------------------------------------------------; %annomac; data ANNO1; length function style color $8 text $50; set mean; tiret='_'; %annomac; %system(2,2); *--color--*; if trt=1 then do; %line(time+0.1,dbp-sem,time+0.1,dbp+sem,olive,2,2); %label(time+0.1,dbp-sem,tiret,olive,0,0,1,simplex,b); %label(time+0.1,dbp+sem,tiret,olive,0,0,1,simplex,b); end; if trt=2 then do; %line(time,dbp-sem,time,dbp+sem,gold,1,2); %label(time,dbp-sem,tiret,gold,0,0,1,simplex,b); %label(time,dbp+sem,tiret,gold,0,0,1,simplex,b); end; proc format; value TRT 1='Treatment X' 2='Treatment Y'; 12

*generate the graph; *------------------; goptions reset=all display cback=white ftext=simplex ftitle=swiss colors=(black) gunit=pct ctext=black htext=3 htitle=2; PhUSE 2006 axis1 axis2 offset=(5,5) label=(h=3 j=r "time point (hours)" ) value=(h=3); offset=(2,2) label=(h=4 angle=90 "Diastolic blood Pressure (mmhg)") value=(h=3) order=(&minval to &maxval by 10); legend1 label=(h=3 'treatement:') position=(top center inside) mode=protect value=(h=3 j=left) across=1; symbol1 i=join value=none line=2 color=olive width=4 h=2; symbol2 i=join value=none line=1 color=gold width=4 h=2; title;footnote; title1 j=c h=4 "Figure X: Annotated plot of mean"; proc gplot data=mean gout=graf; plot DBP*time=trt/ format trt trt.; quit; vaxis=axis2 haxis=axis1 legend=legend1 annotate=anno1; THE GRAPHICS OUTPUT 13

EXAMPLE 5 The Annotate facility can also be used with the GCHART procedure. The coordinates are not X or Y but GROUP and MIDPOINT. The position of the text depends on the bar values (positive or negative) and is positioned using the LABEL macro from the Annotate macro facility. THE PROGRAM data mean; input trt visit mean sem n; cards; 1 1 8 2 9 1 2 7 2 12 1 3 6 1 10 1 4 1 2 15 1 5-1 4 8 2 1 4 3 10 2 2 2 2 11 2 3-2 2 10 2 4-4 1 10 2 5-5 1 9 ; proc sql noprint; select min(mean-sem-1) into:minval from mean; select max(mean+sem+1) into:maxval from mean; quit; %annomac; data ANNO1; length function style color $8 text $50; set mean; %annomac; %system(2,2); Nchar=put(n,2.); *--label the bar with the number of observation per bar--*; if mean>=0 then do; %label(trt,mean,nchar,black,0,0,1,zapfb,2); end; if mean<0 then do; %label(trt,mean,nchar,black,0,0,1,zapfb,8); end; rename visit=group trt=subgroup; proc format; value TRT 1='Treatment X' 2='Treatment Y'; goptions reset=all display cback=white ftext=simplex ftitle=swiss colors=(black) gunit=pct ctext=black htext=3 htitle=2; axis1 label=(h=3 j=right 'Visit') value=(h=3); axis2 label=none value=(h=3) order=(&minval to &maxval by 2) minor=(n=5 color=gray); axis3 label=none value=none offset=(5,5); pattern1 value=r5 color=black; pattern2 value=e color=black; 14

legend1 shape=bar(5,2)cells label=none position=(top center outside) mode=protect value=(j=left h=3 font=hwcgm003); title;footnote; title1 j=c h=4 "Figure X: Annotated barchart"; proc gchart data=mean gout=graf; vbar trt / discrete sumvar=mean width=4 space=1 gspace=1 group=visit subgroup=trt maxis=axis3 raxis=axis2 gaxis=axis1 annotate=anno1 legend=legend1; format trt trt. ; quit; PhUSE 2006 THE GRAPHICS OUTPUT 15

EXAMPLE 6 Instead of adding the number of observation by bar, a indicator of the distribution dispersion could be visualized. The program will be the same as example 5 but the ANNO1 data step should be replace by the following program: THE PROGRAM data ANNO1; length function style color $8 text $50; set mean; tiret='_'; %annomac; %system(2,2); *--add SEM bar--*; if mean>=0 then do; %line(trt,mean+sem,trt,mean,black,1,1); %label(trt,mean+sem,'_',black,0,0,1,simplex,b); end; if mean<0 then do; %line(trt,mean-sem,trt,mean,black,1,1); %label(trt,mean-sem,'_',black,0,0,1,simplex,b); end; rename visit=group trt=subgroup; THE GRAPHICS OUTPUT 16

EXAMPLE 7 For survival plots, the censored events and the number of patients censored could be added as graphics element: THE PROGRAM data _survival; input doselev $1-10 timefailure _censor_ survival; cards; treatment1 0 0 1.00000 treatment1 62 1 1.00000 treatment1 64 0 0.94737 treatment1 78 0 0.89474 treatment1 83 0 0.84211 treatment1 84 0 0.78947 treatment1 85 0 0.63158 treatment1 126 0 0.57895 treatment1 127 0 0.52632 treatment1 148 0 0.47368 treatment1 150 0 0.42105 treatment1 160 0 0.36842 treatment1 353 0 0.31579 treatment1 353 1 0.31579 treatment1 353 1 0.31579 treatment1 353 1 0.31579 treatment1 353 1 0.31579 treatment1 631 0 0.00000 treatment2 0 0 1.00000 treatment2 70 0 0.95000 treatment2 102 0 0.75000 treatment2 102 1 0.75000 treatment2 126 0 0.64286 treatment2 132 0 0.58929 treatment2 187 0 0.53571 treatment2 187 1 0.53571 treatment2 301 0 0.36810 treatment2 302 0 0.35714 treatment2 328 0 0.29762 treatment2 378 0 0.23810 treatment2 378 1 0.23810 treatment2 378 1 0.23810 treatment2 382 0 0.11905 treatment2 397 1 ; proc sort data=_survival; by timefailure doselev ; data _censorp1 (keep=timefailure survival rename=(survival=c1)) _censorp2 (keep=timefailure survival rename=(survival=c2)) _surv1 (keep=timefailure survival rename=(survival=s1)) _surv2 (keep=timefailure survival rename=(survival=s2)); set _survival; by timefailure; if doselev='treatment1' and _censor_=1 then output _censorp1; if doselev='treatment2' and _censor_=1 then output _censorp2; if doselev='treatment1' then output _surv1; if doselev='treatment2' then output _surv2; 17

*--create annotate---*; *====================*; proc sql; *-count number of censored patient by timefailure--*; create table _censorp1b as select put(count(*),2.) as nb_txt,* from _censorp1 group by timefailure,c1; create table _censorp2b as select put(count(*),2.) as nb_txt,* from _censorp2 group by timefailure,c2; quit; *--assign annotate macro facilities---*; %annomac; data anno1; length color $8; set _censorp1b _censorp2b; *--coordinate system: absolute values area--*; %system(2,2); *--label the point with the number of censored patients--*; if C1 ne. then do; %label(timefailure,c1,nb_txt,stg,0,0,1.5,zapf,c);end; if C2 ne. then do; %label(timefailure,c2,nb_txt,biyg,0,0,1.5,zapf,c);end; *--create dataset for the proc Gplot (contains all required variables) for curves and dot plot---*; data _pre_plot; merge _censorp1 _censorp2 _surv1 _surv2; by timefailure; proc sort data=_pre_plot nodupkey; by timefailure C1 C2 S1 S2; goptions reset=all display cback=white ftext=simplex ftitle=swiss colors=(black) gunit=pct ctext=black htext=3 htitle=2; PhUSE 2006 axis1 offset=(2,2) label=(h=2.5 c=green f=zapfbi "Time to Treatment Failure (days) " ) value=(h=2); axis2 offset=(0,0) label=(h=2.5 angle=90 c=green f=zapfbi "Survival Distribution Function Estimate") value=(h=2) offset=(2,2); legend1 label=none position=(top right inside) mode=share across=1 value=(h=2.5 f=zapfi c=stg 'treatment1' 'Censored event (+ nb of censored patients)' c=biyg 'treatment2' 'Censored event (+ nb of censored patients)') ; symbol1 i=stepjr value=none line=2 color=stg width=2 h=2; symbol2 i=none value=dot color=stg width=3 h=3; symbol3 i=stepjr value=none line=1 color=biyg width=2 h=3; symbol4 i=none value=dot color=biyg width=3 h=3; title1 j=c h=4 c=green "Figure X: Survival plot"; 18

proc gplot data=_pre_plot gout=graf; plot S1*timefailure C1*timefailure S2*timefailure C2*timefailure / overlay vaxis=axis2 haxis=axis1 legend=legend1 vref=(&vref2,&vref1) cv=bwh lv=20 href=(&href2,&href1) ch=bwh lh=20 annotate=anno1; quit; THE GRAPHICS OUTPUT PhUSE 2006 EXAMPLE 8 Another possibility with the Annotate facility is to visualize a discontinuation in the axis X or Y. The solution is to create a white solid box on the axis and then add a draw that could symbolize the discontinuation of the axis. Here is an example. THE PROGRAM data a; input xvar yvar zvar $; cards; 1 5 Test_1 2 1 Test_1 3 3 Test_1 4 4 Test_1 5 1 Test_1 6 7 Test_1 7 8 Test_1 8 5 Test_1 9 2 Test_1 19

10 2 Test_1 1 1500 Test_2 2 4000 Test_2 3 3000 Test_2 4 5200 Test_2 5 2000 Test_2 6 4500 Test_2 7 3300 Test_2 8 5300 Test_2 9 7000 Test_2 10 7500 Test_2 ; data anno2; length function style color $8; *--define when to draw annotate: A='After graph' B='before graph'--; retain when 'a'; *--Draw a solid white box to cover the vaxis area where the break occurs.*; %annomac; %system(5,2); %bar(1,42,8,200,white,0,solid);output; *change into white*; * Now draw the jagged line where the vaxis breaks. *; %*system(b,b); %line(4,36.5,7,49,black,1,2);output; *change into black*; %line(4,50,7,350,black,1,2);output; *change into black*; axis1 order=(0 to 10 by 2, 50, 1000 to 10000 by 2000) minor=none width=2; * Produce the plot with annotate2--; title1 h=1.5 'Discontinuous Vaxis (annotate2)'; proc gplot data=a; plot yvar*xvar=zvar / vaxis=axis1 haxis=axis2 anno=anno2; quit; THE GRAPHICS OUTPUT 20

CONCLUSION Creating graphics output using SAS will always be time consuming but thanks to the Annotate facilities, it gives you tools to generate lots of types of graphics. With a little bit of experience, your programming efficiency will considerably increase and SAS/GRAPH won t be such a complicated topic. REFERENCES SAS online doc V8 CONTACT INFORMATION (HEADER 1) Your comments and questions are valued and encouraged. Contact the author at: Sandrine STEPIEN QUINTILES 4 route de la rivière 67380 LINGOLSHEIM Phone: +33(0)3 88 77 44 13 Email: Sandrine.stepien@quintiles.com 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. 21