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



Similar documents
How to Change the Template and Table of Contents for SAS Web Applications Veronica Y. Rath, INDUS Corporation, Vienna, VA

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

Multiple Graphs on One page, the easy way (PDF) and the hard way (RTF)

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

CC03 PRODUCING SIMPLE AND QUICK GRAPHS WITH PROC GPLOT

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

LEGEND OPTIONS USING MULTIPLE PLOT STATEMENTS IN PROC GPLOT

Histogram of Numeric Data Distribution from the UNIVARIATE Procedure

Graphing in SAS Software

Export Customized Graphs Directly into Microsoft Word Using Dynamic Data Exchange

Labels, Labels, and More Labels Stephanie R. Thompson, Rochester Institute of Technology, Rochester, NY

Producing Structured Clinical Trial Reports Using SAS: A Company Solution

Counting the Ways to Count in SAS. Imelda C. Go, South Carolina Department of Education, Columbia, SC

EXST SAS Lab Lab #4: Data input and dataset modifications

PharmaSUG Paper QT26

OVERVIEW OF THE ENTERPRISE GUIDE INTERFACE

Scientific Graphing in Excel 2010

Instant Interactive SAS Log Window Analyzer

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

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

Scatter Plots with Error Bars

SAS UNIX-Space Analyzer A handy tool for UNIX SAS Administrators Airaha Chelvakkanthan Manickam, Cognizant Technology Solutions, Teaneck, NJ

SAS Portfolio Analysis - Serving the Kitchen Sink Haftan Eckholdt, DayTrends, Brooklyn, NY

Math Tools Cell Phone Plans

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

Academic Support Center. Using the TI-83/84+ Graphing Calculator PART II

2 Describing, Exploring, and

Summary of important mathematical operations and formulas (from first tutorial):

McAfee Endpoint Encryption Reporting Tool

Introduction to Microsoft Excel 2007/2010

Using PROC RANK and PROC UNIVARIATE to Rank or Decile Variables

Importing Excel File using Microsoft Access in SAS Ajay Gupta, PPD Inc, Morrisville, NC

SAS Views The Best of Both Worlds

ABSTRACT INTRODUCTION

How Does My TI-84 Do That

One problem > Multiple solutions; various ways of removing duplicates from dataset using SAS Jaya Dhillon, Louisiana State University

Taming the PROC TRANSPOSE

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

Programming Tricks For Reducing Storage And Work Space Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA.

Describing, Exploring, and Comparing Data

Creating Dynamic Reports Using Data Exchange to Excel

Petrel TIPS&TRICKS from SCM

Data Visualization with SAS/Graph

Soma Ghosh, UnitedHealth Group, Minneapolis, MN

HSPA 10 CSI Investigation Height and Foot Length: An Exercise in Graphing

Excel -- Creating Charts

StARScope: A Web-based SAS Prototype for Clinical Data Visualization

5 Correlation and Data Exploration

Regional Drought Decision Support System (RDDSS) Charting Tools Help Documentation

Risk Management : Using SAS to Model Portfolio Drawdown, Recovery, and Value at Risk Haftan Eckholdt, DayTrends, Brooklyn, New York

Using SPSS, Chapter 2: Descriptive Statistics

9.1 SAS. SQL Query Window. User s Guide

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

Search and Replace in SAS Data Sets thru GUI

Publisher 2010 Cheat Sheet

UPK Content Development Rel 12.1

Formulas, Functions and Charts

Salary. Cumulative Frequency

Unit 7 Quadratic Relations of the Form y = ax 2 + bx + c

Combining SAS LIBNAME and VBA Macro to Import Excel file in an Intriguing, Efficient way Ajay Gupta, PPD Inc, Morrisville, NC

Internet/Intranet, the Web & SAS. II006 Building a Web Based EIS for Data Analysis Ed Confer, KGC Programming Solutions, Potomac Falls, VA

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

Beginner s Matlab Tutorial

Lab 1: Introduction to PSpice

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

Storing and Using a List of Values in a Macro Variable

Getting to know your TI-83

Public Health Activities and Services Tracking (PHAST) Interactive Data Visualization Tool User Manual

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

Integrating SAS with JMP to Build an Interactive Application

Excel Tutorial. Bio 150B Excel Tutorial 1

Software Requirements Specification. Web Library Management System

Charting LibQUAL+(TM) Data. Jeff Stark Training & Development Services Texas A&M University Libraries Texas A&M University

Probability Distributions

OS/390 SAS/MXG Computer Performance Reports in HTML Format

Getting Started with R and RStudio 1

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

How to Reduce the Disk Space Required by a SAS Data Set

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

You have got SASMAIL!

Curve Fitting, Loglog Plots, and Semilog Plots 1

SAS BI Dashboard 3.1. User s Guide

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

SAS Enterprise Guide A Quick Overview of Developing, Creating, and Successfully Delivering a Simple Project

Effective Use of SQL in SAS Programming

PharmaSUG Paper AD11

Health Care and Life Sciences

Paper TU_09. Proc SQL Tips and Techniques - How to get the most out of your queries

SAS BI Dashboard 4.3. User's Guide. SAS Documentation

Examples of Data Representation using Tables, Graphs and Charts

Chapter 2 The Data Table. Chapter Table of Contents

Managing Tables in Microsoft SQL Server using SAS

Transcription:

Paper CC01 Multiple Graphs on One Page (Step-by-step approach) Yogesh Pande, Schering-Plough Corporation, Summit NJ ABSTRACT In statistical analysis and reporting, it is essential to provide a clear presentation of analysis results. To achieve this goal, the appearance of figures plays a very important role in data presentation. The most common SAS procedure for generating figures is PROC GPLOT. However, it is necessary to provide a simple solution for the high demand of presenting multiple graphs on one page due to the limitation of GPLOT procedure. The purpose of this paper is to provide user friendly step-by-step instructions in generating multiple graphs on one page by using SAS procedure, PROC GREPLAY. This paper uses features of SAS/GRAPH and its procedures. The explanation is good for O.S. UNIX, Windows Xp. The skill set of the intended audience should be from intermediate to advance level. Key Words: graph, figure, PROC GPLOT, PROC BOXPLOT, PROC GREPLAY, PROC MEANS 1. DEFINITIONS AND KEY WORDS IN SAS GRAPHS Catalog: While creating SAS graphs using PROC GXXXX or PROC BOXPLOT if the programmer uses GOUT option, he/she is creating a graphic catalog. Example: proc gplot data=sashelp.test gout=<catalog-name>; Catalog-name: This catalog-name can be stored in which ever library the user wants to put the catalog. If the library name is not specified it will store those in temporary library WORK. Example: gout=test.graph1 {the graph1 catalog will be stored in library test, incase test. is not written then graph1 catalog will be stored in temporary library work } Goptions: When the user makes graphical catalog, it becomes necessary to use the Goptions nodisplay, but CAUTION, if the user has made graphical catalog and if using goptions nodisplay, it becomes necessary for the user to make use of proper Device. Example: goptions nodisplay device=win Note: If you write all these examples together, the initial step to create SAS GRAPH catalog will be seen as Goptions nodisplay device=win; Proc gplot data=sashelp.test gout=test.graph; This is how the graphical catalog is created. One more important thing about catalog is, the file stored in the catalog Graph cannot be overwritten by another catalog file having same name. For example: PROC GPLOT DATA=INPUT.TEST GOUT=TEST.GRAPH; Where order=1; Plot xxx*yyy ; PROC GPLOT DATA=INPUT.TEST GOUT=TEST.GRAPH; Where order=2; Plot xxx*yyy ; Explanation: In this example even if there are two files of similar names but different plots (as order is different in the where clause) are stored in graph graphic catalog. The catalog will not overwrite these files but the catalog will store this into two files namely gplot and gplot1. Note: The example shown above and the dataset shown above INPUT.TEST is just to simplify the explanation of how catalog files are stored in graphical catalog. The order, xxx and yyy in the where clause are the variables in INPUT.TEST. 2. HOW GREPLAY HELPS IN CREATING MULTIPLE PLOTS? First step: The very first step before we start thinking of how to make 2 or 3 or 4 plots on one page is to check whether the graphical catalog is created properly. The user should also make sure, by what names and how the catalog files are stored in the graphic catalog. 1

For example: Catalog graph (of above example) has graphical catalog files as gplot, gplot1, gplot2 and gplot3. The user has to be sure of the names, because while using PROC GREPLAY user needs to specify the exact catalog file name, just to replay those specific graphs. Second step: The user has to decide weather he/she wants to create his own template or he/she can use available graphical templates in SASHELP.TEMPLT. For example: There are many available templates, few are as given in the Table 1 Templates in SASHELP.TEMPLT H2 H3 L1R2 L2R2S L2R2 Description Horizontal (1 box left, 1 box right) Horizontal (3 box across) 1 box Left 2 boxes Right 2 boxes left and 2 boxes right with space 2 boxes left and 2 boxes Right without space Table 1: Available templates in SASHELP.TEMPLT. Third and final Step: Once the template is decided, if it s the available template then the user needs to just call the template within PROC GREPLAY and make multiple plots on one page (that s our goal). The example below elaborates how to create user-defined graphical template and how multiple plots are constructed on one page. 3. EXAMPLES Example-1: The user is trying to plot four plots (line plots) on one page. He/she doesn t want to use available templates, but wants to create user-defined template. Create 4 frames (in this example I am creating 4 plots on one page) on one page, these 4 frames will display 4 graphs in a very organized manner. These frames can be created by PROC GREPLAY. Please see the code at Fig. 1. GOPTIONS DISPLAY; proc greplay nofs igout=work.test tc=tempcat; tdef spec4 des='four panel template' 1/ LLX=0 LLY=0 ULX=0 ULY=50 Frame 1 URX=50 URY=50 LRX=50 LRY=0 2/ LLX=0 LLY=50 ULX=0 ULY=100 Frame 2 URX=50 URY=100 LRX=50 LRY=50 3/ LLX=50 LLY=50 ULX=50 ULY=100 URX=100 URY=100 Frame 3 LRX=100 LRY=50 4/ LLX=50 LLY=0 ULX=50 ULY=50 URX=100 URY=50 Frame 4 LRX=100 LRY=0 ; template spec4; treplay 1:gplot 2:gplot1 3:gplot2 4:gplot3 Delete _ALL_; Run; Quit; Figure 1: PROC GREPLAY user defined template code 2

Explanation: proc greplay nofs igout=work.test tc=tempcat; tdef spec4 des='four panel template' NOFS = Suppress the PROC GREPLAY screen to appear. IGOUT= The graphic catalog, where the graphs are stored. TC = The name where user defined template spec4 will be stored. DES = The description of the spec 4 created template < optional> The user defined Template tdef, has four frames and PROC GREPLAY enables the user to define those four frames. The frames are defined by the parameters as explained below. (Please look at the above code while reading the definition of these parameters) LLX = Lower Left X- axis ULX = Upper Left X- axis URX = Upper Right X-axis LRX = Lower Right X-axis LLY = Lower Left Y axis ULY = Upper Left Y axis URY = Upper right Y axis LRY = Lowe Right Y-axis I) The value written in front of these parameters LLX, LLY is in accordance with the A4 page size. This means that LLX=0 will be the point at the origin of the X-axis and LLY=0 will also be the point at the origin of the Y-axis. Thus the Frame 1 first point will be (0, 0). Similarly other points makes FRAME 1 complete (please see figure 2) (ulx, uly) 0,50 50,50 (urx, ury) Frame 1 of PROC GREPLAY (llx, lly) 0,0 50,0 Landscape dimensions (lrx, lry) Figure 2: Frame construction of PROC GREPLAY II) III) The Frame 1 of PROC GREPLAY covers the 50 % of x-axis and 50 %of Y-axis. Similarly all other frames (Frame 2, Frame 3 and Frame 4) are constructed by the user defined template "spec4", as seen below. 3

Frame 2 Frame 3 Frame-1 Frame 4 The example show below uses the sample dataset; please click the link to download the dataset, in order to better understand the code written below. Example : http://rs301.rapidshare.com/files/202402733/data.txt PROC FORMAT; value days 0='Base' 1='Day 1' 2='Day 2' 3='Day 3' 4='Day 4' 5='Day 5' 6='Day 6' 7='Day 7' ; *------------------------------------------------------------------------ Note: Removing all the formats (if any) associated with the variables assigning format to the 'Days' variable which will be x-axis for the plots DATA sample; SET current.show; *--Download this dataset to better understand the code; FORMAT _ALL_; FORMAT days days.; *-----Sorting the data set by sequence, days and group each player belongs to------; PROC SORT; BY sequence days group; *------------------------------------------------------------------------ Note: Taking the median of the 'Scores' given by the trainer during the training (This median of the 'Scores' variable will be plotted) PROC MEANS DATA=sample NOPRINT; BY sequence days group; VAR score; OUTPUT OUT=testing1 (DROP=_TYPE FREQ_) MEDIAN=MEDIAN; 4

*------------------------------------------------------------------------ This PROC MEANS is to get an idea about the Y-AXIS range of the MEDIAN. This min and max will be used later on to plot the values for x-axis and y-axis PROC MEANS DATA=testing1 NOPRINT; BY sequence; VAR MEDIAN days; OUTPUT OUT=testing2 MIN= Y_MIN X_MIN MAX= Y_MAX X_MAX; *------------------------------------------------------------------------ Creating MACRO variables for ranges of various Sequence. As the plots are by Sequence these macro variables will give an idea about the minimum and maximum values that are seen on X-axis and Y-axis data _null_; set testing2; call symputx("x_min" CATC(sequence),X_MIN); call symputx("x_max" CATC(sequence),X_MAX); call symputx("y_min" CATC(sequence),CEIL(Y_MIN-1)); call symputx("y_max" CATC(sequence),CEIL(Y_MAX+1)); %put &x_min1 &x_max1 &y_min1 &y_max1; %put &x_min2 &x_max2 &y_min2 &y_max2; %put &x_min3 &x_max3 &y_min3 &y_max3; %put &x_min4 &x_max4 &y_min4 &y_max4; %Multi_GRAPH (SEQ1=1, SEQ2=2, SEQ3=3, SEQ4=4, LABEL1=Sequence 1, LABEL2=Sequence 2, LABEL3=Sequence 3, LABEL4=Sequence 4, N2=4, Y_SPACE1=2, Y_SPACE2=4, Y_SPACE3=4, Y_SPACE4=4) *----------------------------------------------------------------------- About %MULTI_GRAPH macro Purpose: To create 4 plots on one page by PROC GREPLAY Note : This macro uses PROC GPLOT features to create graphs. Parameter Explanation: SEQ1-SEQ4 = The sequence numbers in the dataset, each sequence number will constitute one plot. So here in this macro we need to declare 4 sequence numbers so that 4 graphs are plotted. Label1-Label4 = The title that each graph should display on the top. N2 = As we need to use PROC GPLOT 4 times, this key macro parameter will iterate 4 times PROC GPLOT as there are four sequence. (Basically used in %DO %END statement (see the macro for further details) YSPACE1-YSPACE4 = These key parameters is to define the gap between each point on Y-axis - %MACRO Multi_GRAPH(SEQ1=,SEQ2=,SEQ3=,SEQ4=,SEQ5=,LABEL1=,LABEL2=,LABEL3=, LABEL4=, LABEL5=, N2=, Y_SPACE1=, Y_SPACE2=, Y_SPACE3=, Y_SPACE4=); symbol1 i = join c = red l=1 w = 1.75 value=1 h=2; symbol2 i = join c = blue l=2 w = 1.75 value=2 h=2; symbol3 i = join c = green l=3 w = 1.75 value=3 h=2; symbol4 i = join c = black l=4 w = 1.75 value=4 h=2; 5

%DO I=1 %TO &N2; axis1 order=(&&&&x_min&&seq&i to &&&&X_MAX&&SEQ&I by 1) label=(angle=0 H=2 font=simplex "Training Days"); axis2 order=(&&&&y_min&&seq&i to &&&&y_max&&seq&i by &&y_space&i ) label=(angle=90 H=2 font=simplex "Median of scores"); title1 h=2 font='swissb' "&&label&i"; title2 h=2 font='simplex' "(Base, Day 1-Day 7)"; Legend1 label=(f=swiss h=2 c=black position=left justify=center "Type of Training") position=(bottom center outside) value=(h=2 ); GOPTIONS nodisplay device=win; proc gplot data=testing1 GOUT=TEST ; WHERE SEQUENCE=&&SEQ&I; plot median*days=group /haxis=axis1 vaxis = axis2 legend=legend1 ; run; quit; %END; proc greplay nofs igout=work.test tc=tempcat; tdef spec4 des='four panel template' 1/ llx=0 lly=0 ulx=0 uly=50 urx=50 ury=50 lrx=50 lry=0 2/ llx=0 lly=50 ulx=0 uly=100 urx=50 ury=100 lrx=50 lry=50 3/ llx=50 lly=50 ulx=50 uly=100 urx=100 ury=100 lrx=100 lry=50 4/ llx=50 lly=0 ulx=50 uly=50 urx=100 ury=50 lrx=100 lry=0 ; template spec4; treplay 1:gplot 2:gplot1 3:gplot2 4:gplot3; DELETE _ALL_; run; quit; %MEND Multi_GRAPH; The result of the above code is as shown in Figure 3. 6

Figure 3: Four plots on one page (This plot is by Sequence) 4. CONCLUSION This paper has examined and explained in a simplistic step-by-step approach towards creating MUTIPLE plots on one page. The basic idea about what goes behind PROC GREPLAY has been explained in detail. This paper has also explained a macro that can be used to generate four plots for similar type of data. I hope that after going through this paper user will be more comfortable in using SAS/GRAPH when it comes to plotting multiple plots on one page. 5. REFERENCE SAS/GRAPH Software: version 9, SAS Institute Inc., Cary NC SAS/Graph help online documentation: Version 9, SAS Institute Inc,, Cary NC SAS Institute, Inc. (1990), SAS/Graph Software: Reference, First Edition, Cary, NC: SAS Institute, Inc. Acknowledgement: I would like to Thank Ms. Annpey Pong for her valuable comments. Contact Information: Your comment and questions are valued and encouraged. Yogesh Pande Sr. Clinical Programmer Schering-Plough Clinical Programming Dept. 556 Morris Ave., Summit NJ 07901 Phone: 908-473-5574 Email: yogesh.pande@spcorp.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. 7