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

Similar documents
separate representations of data.

Modifying Graphics in SAS

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

CHAPTER 1 Introduction to SAS/GRAPH Software

INTRODUCTION TO THE SAS ANNOTATE FACILITY

Handout 4 - Interpolation Examples

Creating Forest Plots Using SAS/GRAPH and the Annotate Facility

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

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

From Getting Started with the Graph Template Language in SAS. Full book available for purchase here.

Introduction to SAS/GRAPH Statistical Graphics Procedures

The Plot Thickens from PLOT to GPLOT

8. MINITAB COMMANDS WEEK-BY-WEEK

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

Introduction to Minitab 1

Picturing Statistics Diana Suhr, University of Northern Colorado

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

Bar Graphs with Two Grouping Variables 1

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

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

Data Analysis Guidelines

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

Open a new Excel workbook and look for the Standard Toolbar.

Fathom Dynamic Data TM Version 2 Specifications

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

Here is the data collected.

Making Science Graphs and Interpreting Data

ENV Laboratory 2: Graphing

W7 DATA ANALYSIS 2. Your graph should look something like that in Figure W7-2. It shows the expected bell shape of the Gaussian distribution.

Why Use Graphs? Test Grade. Time Sleeping (Hrs) Time Sleeping (Hrs) Test Grade

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

Applied Regression Modeling: A Business Approach

Spreadsheet and Graphing Exercise Biology 210 Introduction to Research

An alternative view.

Graphing on Excel. Open Excel (2013). The first screen you will see looks like this (it varies slightly, depending on the version):

Coders' Corner. Paper ABSTRACT GLOBAL STATEMENTS INTRODUCTION

SAS Programs SAS Lecture 4 Procedures. Aidan McDermott, April 18, Outline. Internal SAS formats. SAS Formats

Type of graph: Explain why you picked this type of graph. Temperature (C) of product formed per minute)

Chapter 5 Accumulating Change: Limits of Sums and the Definite Integral

UTILIZING SAS TO CREATE A PATIENT'S LIVER ENZYME PROFILE. Erik S. Larsen, Price Waterhouse LLP

Experimental Design and Graphical Analysis of Data

Brief Guide on Using SPSS 10.0

Extending ODS Output by Incorporating

Lab #9: ANOVA and TUKEY tests

Getting Started with the SGPLOT Procedure

Creating a Box-and-Whisker Graph in Excel: Step One: Step Two:

LAB 1 INSTRUCTIONS DESCRIBING AND DISPLAYING DATA

Dealing with Data in Excel 2013/2016

Chapter 6: DESCRIPTIVE STATISTICS

Math 1525: Lab 4 Spring 2002

Homework 1 Excel Basics

Introduction to the workbook and spreadsheet

Chapter 10 Working with Graphs and Charts

Using PC SAS/ASSIST* for Statistical Analyses

Chapter 4: Linear Relations

Things to Know for the Algebra I Regents

Logical operators: R provides an extensive list of logical operators. These include

Descriptive Statistics, Standard Deviation and Standard Error

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

Error-Bar Charts from Summary Data

Bar Graphs with One Grouping Variable 1

SAS CLINICAL SYLLABUS. DURATION: - 60 Hours

1. Basic Steps for Data Analysis Data Editor. 2.4.To create a new SPSS file

STA 570 Spring Lecture 5 Tuesday, Feb 1

Chapter 5. Normal. Normal Curve. the Normal. Curve Examples. Standard Units Standard Units Examples. for Data

Multiple Forest Plots and the SAS System

The Power and Sample Size Application

Lab 4 Projectile Motion

Introduction to Statistical Graphics Procedures

Combining a Bar Graph with a Line Graph 1

Middle Years Data Analysis Display Methods

Tricking it Out: Tricks to personalize and customize your graphs.

Graphical Techniques for Displaying Multivariate Data

Scatterplot: The Bridge from Correlation to Regression

Points Lines Connected points X-Y Scatter. X-Y Matrix Star Plot Histogram Box Plot. Bar Group Bar Stacked H-Bar Grouped H-Bar Stacked

Desktop Studio: Charts. Version: 7.3

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

Data Management Project Using Software to Carry Out Data Analysis Tasks

Microscopic Measurement

Applied Regression Modeling: A Business Approach

Year 10 General Mathematics Unit 2

Select the Points You ll Use. Tech Assignment: Find a Quadratic Function for College Costs

Creating and Modifying Charts

Activity: page 1/10 Introduction to Excel. Getting Started

Name Date Types of Graphs and Creating Graphs Notes

Working with Charts Stratum.Viewer 6

Tips and Guidance for Analyzing Data. Executive Summary

a. divided by the. 1) Always round!! a) Even if class width comes out to a, go up one.

Desktop Studio: Charts

Unit 1, Lesson 1: Moving in the Plane

Excel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division

IMPROVING A GRAPH USING PROC GPLOT AND THE GOPTIONS STATEMENT

Using Excel to produce graphs - a quick introduction:

Graphical Analysis of Data using Microsoft Excel [2016 Version]

Reference and Style Guide for Microsoft Excel

Excel Spreadsheets and Graphs

WHOLE NUMBER AND DECIMAL OPERATIONS

Your Name: Section: INTRODUCTION TO STATISTICAL REASONING Computer Lab #4 Scatterplots and Regression

Unit 0: Extending Algebra 1 Concepts

28 CHAPTER 2 Summarizing and Graphing Data

Transcription:

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

Introduction to SAS/GRAPH Graphics component of SAS system. Includes charts, plots, and maps in both 2 and 3 dimensions. Procedures included GCHART, GPLOT, GMAP, GCONTOUR etc We will focus on PROC GPLOT

What can be done with SAS/GRAPH? These samples courtesy of Robert Allison s SAS Graph Examples

Elements of SAS/GRAPH Overview Global Statements ODS Destination Elements Procedure Step Taken from SAS 9.2 documentation

Elements of SAS/GRAPH PROC GPLOT: Specifying an input data set Similar to all other SAS PROC s Proc gplot data=<libname>.<data set><options>; Options include setting annotate data sets, image mapping for drill-down plots in web applications, Creating Uniform axis across plots, and specifying SAS catalog for placement of output.

Elements of SAS/GRAPH PROC GPLOT: Plotting You can use up to 2 plots statements at a time, however, at least one Plot statement is required. The plot statement is used to control the axis, plotting points, labels, tick marks, and the plot legend. The only required arguments are Plot <Y Variable>*<X Variable> / <options>;

Elements of SAS/GRAPH PROC GPLOT: Plotting Options Options for plotting Plot options Legend= or nolegend: specifies figure legend options Overlay: allows overlay of more than one Y variable Skipmiss: breaks the plotting line where Y values are missing Appearance option Axis: Specifies axis label and value options Symbol: Specified symbol options href, vref: Draws vertical or horizontal reference lines on plot frame/fr or noframe/nofr: specifies whether or not to frame the plot caxis/ca, cframe/cfr, chref/ch, cvref/cv, ctext/c: specifies colors used for axis, frame, text or reference lines.

Introduction to SAS/GRAPH We will begin with rather simple code and let SAS decide how our graph will look. Then we will step through a few options that allow us to control and adjust the graphic output.

2 Variable Plotting / Scatter plots

2 Variables Suppose subjects are given a doses of experimental medication based on body weight over a 24 hour period (mg/24hrs). Variable X On the following day, each subject had their Vascular Cell Adhesion Molecule (μg/ml) levels measured. Variable Y1 The investigators are interested in seeing a plot of the dose given vs. the plasma VCAM levels to see if there may be an effect of the drug dose.

2 Variables Very basic plot, below we get all of the default options. Not very exciting. Definitely not publication quality. y1 3 Cannot read axis marks 2 Crowded Axis 1 Axis labels don t describe the data 0 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 x

2 Variables: AXIS Statements AXIS<1..99> <options>; Label Option; Angle/a=degrees (0-359) Color/c=text color Font/f=font Height/h=text height (default=1) Justify=(left/center/right) Label= text string Options precede label axis1 label=(a=90 c=black f= arial h=1.2 time a=90 c=black f= arial h=1.0 hours );

2 Variables: AXIS Statements AXIS<1..99> <options>; Order Option Order=(a to b by c): major tick marks will show up at intervals based on c. Example order=(0 to 3 by 1); Value Option value=( ): applies text label to each major tick. Example Value=( Start Middle End )

2 Variables: AXIS Statements Resets previous options Horizontal axis (X Variable) Vertical axis (Y Variable) Call Axis statements NOTE: you can also place the AXIS statements within the gplot proc

2 Variables: AXIS Statements 3 The LABEL options helped make the axis labels meaningful, but the axis tick marks remain crowded 2 Plasma Level 1 0 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 Dose m g/24 Hrs

Added ORDER option to Axis statement Examples 2 Variables: AXIS Statement

2 Variables: AXIS Statement 3 2 Plasma Level 1 The axis are less crowded, but still very hard to read, using the Value= option will help. 0 0.0 0.5 1.0 1.5 2.0 Dose m g/24 Hrs

Added VALUE option to Axis statement Examples 2 Variables: AXIS Statement

2 Variables Plasma Level 0.0 1.0 2.0 3.0 0.0 0.5 1.0 1.5 2.0 Dose m g/24 Hrs Now about those data points!

2 Variables: Symbol Statement Symbol<1 255> <options>; Symbol options Color= value color Ci=line color Height=symbol height Line=line type Value=symbol Width=thickness factor Interpol=point interpolations

2 Variables: Symbol Statement Symbol<1 255> <options>; Symbol options Interpolation options Join, box, hilo interpolation, regression, spline, standard deviations. value options Dot, circle, star, square, plus, minus, text value. Color options 256 colors available, www.devenezia.com/docs/sas/sas-colors.html

Symbol options Examples 2 Variables: Symbol Statement Interpolation options None Join: points connected by straight line Needle: vertical line from horizontal axis to point Stepx: (L,R,C) step function, stepxj will add a verticle line to each step plot stdkxxx: (M,P,J,B,T) k=1,2,3 (standard deviations) or» stdm=sem, stdp=uses pooled sample variance, stdj=joins the errors, T will give tops and bottoms to error lines, where B will request error bars. HILOxxx: (T,B,C,J)

Symbol options Examples 2 Variables: Symbol Statement Interpolation options R-series interpolation Rxxxxxxx» RL: linear regression» RQ: Quadratic Regression» RC: Cubic Regression» CLM: CI for mean predicted values» CLI: CI for Individual predicted values» 90, 95, 99: confidence limits

2 Variables: SYMBOL Statement Plasma Level 0.0 1.0 2.0 3.0 0.0 0.5 1.0 1.5 2.0 Dose m g/24 Hrs

Regression Equation: y 1 = 0.481173 + 1.269433*x Examples 2 Variables: Adding Regression Lines Plasma Level 0.0 1.0 2.0 3.0 0.0 0.5 1.0 1.5 2.0 Dose m g/24 Hrs

Grouping Variables Many times we want to look at group differences. Demographic groups, treatment groups, etc Grouping variable must be in the data file.

Grouping Variables You need to add a new SYMBOL statement for the each additional group. Add the grouping variable to the PLOT statement

Grouping Variables Plasma Level 0.0 1.0 2.0 3.0 0.0 0.5 1.0 1.5 2.0 Dose mg/24 Hrs Not bad, but the figure legend is not well placed. gender Female Male

Grouping Variables: Legend Statement Legend<1 99> <options>; Legend options Across=: number of columns Down=: number of rows Frame/noframe Position=(bottom, middle, top) (left, center, right) (inside, outside) Origin=(x,y) Label= Order= Value= These options are the same as within the axis statement discussed earlier

Grouping Variables: Legend Statement Legend Statement Call Legend Statement

Grouping Variables: Legend Statement Plasma Level 0.0 1.0 2.0 3.0 0.0 0.5 1.0 1.5 2.0 Dose m g/24 Hrs Gender Female Male

Repeated Measures/Longitudinal Plotting

Repeated Measures/Longitudinal Plotting Suppose that you have many observations on each subject taken at various time points. 40 subjects 2 treatments (Placebo and Active med) 5 time points (baseline plus 4 1-week intervals) During the last week, both treatment groups receive Placebo Data should be in the Long format At diagnosis, subjects are randomized to an experimental treatment or placebo. During the final week of treatment, all subjects will receive active medicatio.

Repeated Measures/Longitudinal Plotting Create appropriate axis and legend statements as before. AXIS for X (time) variable AXIS for Y (Response) variable Added TITLE statement for plot

Repeated Measures/Longitudinal Plotting Individual Disease Progression 100 90 80 70 Response 60 50 40 30 20 10 0 Baseline 1 2 3 4 Tim e Since Diagnosis: W eeks

Repeated Measures/Longitudinal Plotting Joins the dots, By ID Individual Disease Progression 100 90 80 70 Response 60 50 40 30 20 10 0 Baseline 1 2 3 4 Tim e Since Diagnosis: W eeks

Repeated Measures/Longitudinal Plotting Individual Disease Progression Plot data by trt group and create a symbol statement for each group 100 Treatment Group Tre a tm a n t A P la c e b o 90 80 70 Response 60 50 40 30 20 10 0 Baseline 1 2 3 4 Tim e Since Diagnosis: W eeks

Using the Overlay statement to stack plots

Overlay 2 plots w/ the same data Suppose that you are asked to graphically show progression of tumor growth for a group of subjects and overlay the progression of each treatment group. 50 subjects randomized to either low or high dose medication. Tumor size is measured at baseline as well as the following 9 weeks. The investigator would like an easy to present plot containing both pieces of information for a presentation to his peers.

Overlay 2 plots w/ the same data Plot of individual values as before 80 70 Individual Disease Progression 60 Tumor Growth 50 40 30 Grouping variable Symbol repeats 20 10 0 Plot of treatment group means and Standard errors as before Baseline 1 2 3 4 5 6 7 8 9 Time Since Diagnosis: Weeks 80 Treatment Group Low Dose High Dose Individual Disease Progression 70 60 Tumor Growth 50 40 30 20 10 0 Baseline 1 2 3 4 5 6 7 8 9 Time Since Diagnosis: Weeks

Overlay 2 plots w/ the same data

80 Examples Overlay 2 plots w/ the same data Treatment Group Low Dose High Dose Individual Disease Progression 80 70 70 60 60 Tumor Growth 50 40 30 50 40 30 20 20 10 10 0 Baseline 1 2 3 4 5 6 7 8 9 Time Since Randomization: Weeks 0

Overlay multiple plots from different variables Use proc logistic to output the predicted probability of developing nephropathy given the baseline Oxidized LDL immune complex level as well as the 95% confidence limits. Many PROCs can output predicted values, adjusted means, along with point wise confidence values.

Overlay multiple plots from different variables 0.8 Prob. of Nephropathy (95% CI) 0.6 0.4 0.2 0.0 1.80 2.14 2.48 2.82 3.16 3.50 3.84 4.18 4.52 4.86 5.20 5.54 5.88 6.22 6.56 6.90 Baseline Ox LDL-IC

Overlay multiple plots from different variables 250 Baseline Characteristics OxLDL-IC LDL Cholesterol HDL Cholesterol 500 Baseline LDL & HDL (mg/dl) 200 150 100 50 400 300 200 100 Baseline OxLDL-IC 0 0 1st 2nd 3rd 4th Baseline OxLDL-IC Quartile

Overlay multiple plots from different variables

The Annotate Facility

The Annotate Facility Introduction The Annotate Facility allows SAS users to customize graphical output. The customizations can be data driven or user specified. Text, shapes, lines and images can be added to output graphics Step 1. Create an annotate data set this data file will give commands to SAS/GRAPH Specific variables must be in the annotate data set. Others are allowed but ignored What, how, and where are defined by these variables. Table 1 list important variables.

The Annotate Facility Introduction

The Annotate Facility Introduction The Annotate FUNCTION variable tells SAS what to do The annotate coordinate system allows for flexibility in placing objects within the output. There are 12 possible conditions.

The Annotate Facility Introduction Taken from Mink and Pasta, SUGI 31

The Annotate Facility Introduction

The Annotate Facility Proc GPLOT global options help make graphs more pleasing, however, there are cases where more work is needed to fully explain the data 10.0 % Mean HbA1c % durring DCCT/EDIC study 9.5 % 9.0 % 8.5 % HbA1c 8.0 % 7.5 % 7.0 % 6.5 % 6.0 % BL 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 Study Time Years

The Annotate Facility

The Annotate Facility Deleted regions of non interest Created shaded regions to designate study sections Added treatment group and study section labels

The Annotate Facility Individual Net Worth As a Function of Original Worth $ 1.00 $ 0.90 $ 0.80 $ 0.70 $ 0.60 $ 0.50 $ 0.40 $ 0.30 $ 0.20 $ 0.10 $ 0.00 BORING! Suppose you want To jazz up your plots for a Presentation. You can place a picture Or graphic behind you data to accent The results. We are going to place an image behind the data, but only below The data series. NEAT! Jan. 2007 Jan. 2008 Jan. 2009 Jan. 2010 Jan. 2011 Year

The Annotate Facility Anno data set 1: Will place the image of the dollar over the plotting area. Anno data set 2: Will create white Space above the Plotted line over time. SET the anno data sets and call them in the GPLOT statement

The Annotate Facility Individual Net Worth As a Function of Original Worth $ 1.00 $ 0.90 $ 0.80 $ 0.70 $ 0.60 $ 0.50 $ 0.40 $ 0.30 $ 0.20 $ 0.10 $ 0.00 Jan. 2007 Jan. 2008 Jan. 2009 Jan. 2010 Jan. 2011 Year

The End