TS02 SAS GTL - Injecting New Life into Graphs

Slides:



Advertisements
Similar presentations
Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
Advertisements

Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Taking the Leap - Using ODS Statistical Graphics for Data Visualization Wei Cheng, Isis Pharmaceuticals, Inc.
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Using ODS Regions to Create Custom Reports Kate Morrow, M.S. Statistician Vermont Oxford Network, Burlington, VT.
® Microsoft Office 2010 Excel Tutorial 4: Enhancing a Workbook with Charts and Graphs.
Templates and Styles Excel Advanced. Templates are pre- designed and formatted spreadsheets –They provide consistency of layout/structure –They.
Stat-JR: eBooks Richard Parker. Quick overview To recap… Stat-JR uses templates to perform specific functions on datasets, e.g.: – 1LevelMod fits 1-level.
Programming Logic and Design Fourth Edition, Introductory
Excel Graphing Tutorial Lauren Ottaviano Fall 2012.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
Charts and Macros Pretty Pictures. Charts Graphical display of information Often referred to as “Visualization” Allows a more innate grasp of numeric.
Developing Effective Reports
DT228/3 Web Development JSP: Directives and Scripting elements.
CS1100: Computer Science and Its Applications Creating Graphs and Charts in Excel.
Copyright © 2007, SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks.
How to Build Tabular Dashboards Using Proc Report
Dashboards With PROC GKPI September 25, 2009 Barry Hong
Graphical Reporting of Clinical Trial Data with SAS ODS Graphics
Bay Area SUG June SAS ® 9.2 Implications for Biotech SAS ® 9.2 Implications for Biotech Bay Area SAS User’s Group June 7 th 2010 Sarmad Pirzada,
XP Chapter 5 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Developing Effective Reports Chapter 5 “Nothing succeeds.
Term 2, 2011 Week 1. CONTENTS Types and purposes of graphic representations Spreadsheet software – Producing graphs from numerical data Mathematical functions.
Spreadsheet-Based Decision Support Systems Chapter 22:
The Project – Spreadsheet Design. The following is the high mark band for the spreadsheet design: The candidate has Analysed a given data set and designed.
PROC GREPLAY With Templates December 5, 2008 Barry Hong Process Analysis and Simulation U. S. Steel Canada © 2008 United States Steel Corporation.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
Tips & Tricks MASUG02/18/2005. Multiple Graphs on One Page.
Chapter 5: Charts Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
LECTURE -9 CREATING A CHART IN MICROSOFT EXCEL. CHARTS Picture representation of data used Easy understanding Comparison of data Checking trends in data.
Report Management Using the ODS DOCUMENT Destination and Report Metadata Brit Harvey February 2010.
Multiple Uses for a Simple SQL Procedure Rebecca Larsen University of South Florida.
ODS Statistical Graphics in SAS 9.2 January 17, 2010.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
Introduction to SAS/Graph 9.2 Ken Barz Colorado Prevention Center 22Oct2009 Ken Barz Colorado Prevention Center.
Advanced Stata Workshop FHSS Research Support Center.
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Copyright © 2014, SAS Institute Inc. All rights reserved. ACCESSIBILITY TIPS AND TRICKS FOR SAS PROGRAMMERS ED SUMMERS SENIOR MANAGER, ACCESSIBILITY.
ON PATHS LESS TRODDEN… Excursions in SAS/GRAPH ® and PROC TABULATE Presented by Aaron Rabushka © Aaron Rabushka 2000.
Priya Ramaswami Janssen R&D US. Advantages of PROC REPORT -Very powerful -Perform lists, subsets, statistics, computations, formatting within one procedure.
Statistical Graphics for the SAS System Computing for Research I 01/29/2014 Nathaniel L Baker.
Effective SAS greplay’ing and how to avoid stretching By David Mottershead Senior Programmer, Quanticate.
PROC GPLOT GPLOT is used to make two dimensional scatter-plots. General Syntax: proc gplot data=data-set options; plot y-variable*x-variable/options; run;
MASUG September 15, Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks 
Walkthrough example including SAS output How to create a mobile WebApp? PhUSE / 12. October 2015 / Katja Glaß BHC 4:3 Template 2010 June 2014Page 1.
Kaitlyn McConville, Rho ®, Inc. Kristen Much, Rho ®, Inc. PharmaSUG 2015 Paper #DV02.
Chapter 15: Spreadsheet and Worksheet Basics Lesson 96: Worksheets with Charts © 2010, 2006 South-Western, Cengage Learning.
1 Chapter 3: Getting Started with Tasks 3.1 Introduction to Task Dialogs 3.2 Creating a Listing Report 3.3 Creating a Frequency Report 3.4 Creating a Two-Way.
SAS ® is a very powerful tool when producing Graphics. A single graphical data step can easily create a Kaplan Meier Plot, but there is no single graphical.
SAS/GRAPH The Basics. Today’s Topics GOPTIONS GPLOT GCHART GCONTOUR G3D.
SAS Beyond TFLs: An Application as a Statistician’s Tool William Coar Date: 10/15/2009 Denver SAS User’s Group.
Introduction to SAS ODS Graphics September 16, 2015 Rocio Lopez.
PROC CATALOG The Wish Book SAS® Procedure. 2 PROC CATALOG, the Wish Book SAS® Procedure Louise S. Hadden Abt Associates Inc. PROC CATALOG, the Wish Book.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
SAS GTL. What we’re going to cover… Some basics Layouts Plots Examples.
Determination of efficient pricing periods using SAS prepared by Voytek Grus for SAS user group, Halifax April 30, 2010.
Behind the Scenes with SAS®: Using Customer Graphics in SAS® Output Louise Hadden Abt Associates Inc.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
Forest Plotting Analysis Macro %FORESTPLOT (Paper 3419)
ODS Graphics By Example March 16, 2016 Rocio Lopez.
Tutorial 4: Enhancing a Workbook with Charts and Graphs
Chapter 8: ODS Graphics ODS graphics were not available prior to SAS 9.2 They have been implemented across a wide range of procedures Functionality isn’t.
ON PATHS LESS TRODDEN… Excursions in SAS/GRAPH® PROC TABULATE and
Use of SAS® Graph Template Language and HIGHLOWPLOT to Create a Next-Generation Sequencing Multi-Gene Panel Grid John Bennett Statistical Programmer Genomic.
Click Headings Above to View Content
Topic 7: Visualization Lesson 1 – Creating Charts in Excel
Author: Kaiqing Fan Company: Mastech Digital Inc.
Making a Publication-quality Graph in SAS
SAS/Graph to help data Dose/Concentration consistency review
Presentation transcript:

TS02 SAS GTL - Injecting New Life into Graphs Lawrence Heaton-Wright, Quintiles

SAS GTL - Injecting New Life into Graphs What is GTL? Comparison of Traditional and GTL Simple Plots Common Tasks Multiple Plots On One Page Dynamic Templates ODS Graphics Conclusion Questions

What is GTL? Graph Template Language (GTL) is an addition to SAS/Graph for Version 9. Allows analytical graphics to be produced that are not available with traditional SAS/Graph procedures GTL graphics are produced by rendering data into a graph format template This allows the user a lot of flexibility for using these templates with different data sources The aim of this presentation is to Compare tasks undertaken using traditional SAS/Graph techniques and GTL Provide an introduction to using dynamic templates

Simple Plots - Traditional GOPTIONS RESET=GOPTIONS DEVICE=WIN TARGETDEVICE=PNG FTEXT="Arial" HTEXT=11pt HBY=0 HTITLE=11pt CPATTERN=GREY; AXIS1 ORDER=(0 TO 500 BY 50) MINOR=NONE LABEL=("Horse Power"); AXIS2 ORDER=(0 TO 70 BY 10) MINOR=NONE LABEL=(A=90 "MPG (Highway)"); SYMBOL1 COLOR=BLACK VALUE=CIRCLE; SYMBOL2 COLOR=BLACK VALUE=SQUARE; SYMBOL3 COLOR=BLACK VALUE=TRIANGLE; LEGEND1 FRAME ACROSS=1 LABEL=("Origin of Car"); TITLE1 "PhUSE 2010"; TITLE2 "Example GPLOT"; PROC GPLOT DATA=cars; PLOT mpg_highway * horsepower = origin / HAXIS=AXIS1 VAXIS=AXIS2 LEGEND=LEGEND1; RUN;QUIT; This is a fairly simple scatter plot The traditional code layout defines the axes, symbol attributes, legend and titles The procedure then creates the graph based on the input data and applies the previously defined axes, symbols, legend and titles to the final output

Simple Plots – GTL PROC TEMPLATE; DEFINE STATGRAPH scatter; BeginGraph; EntryTitle "PhUSE 2010"; EntryTitle "Example GTL"; Layout OVERLAY; ScatterPlot X=horsepower Y=mpg_highway / GROUP=origin NAME="scatter"; DiscreteLegend "scatter" / ACROSS=3 TITLE="Origin of Car"; EndLayout; EndGraph; END; RUN; PROC SGRENDER DATA=cars TEMPLATE=scatter; The Layout OVERLAY statement builds a composite of one or more graphics statements Using GTL we define the type of graph, titles and legend The SGRENDER procedure then renders the data into the template defined GTL defines the symbols and axes definitions without programmer input (although this can be programmed)

Common Tasks - Traditional Create an annotate data set for the vertical bars and tick marks %annomac; DATA anno; SET summary; %SYSTEM(2, 2); IF stddev GT 0 THEN DO; %LINE(engine, mean-stddev, engine, mean+stddev, black, 1, 1); %LINE(engine-0.05, mean-stddev, engine+0.05, mean-stddev, black, 1, 1); %LINE(engine-0.05, mean+stddev, engine+0.05, mean+stddev, black, 1, 1); END; RUN; Define axes, symbols, legend as usual Apply the annotate data set using the ANNOTATE option AXIS1 ORDER=(0 TO 6) MINOR=NONE LABEL=("Engine Size"); AXIS2 ORDER=(0 TO 500 BY 50) LABEL=(A=90 "Mean Horsepower");   SYMBOL1 COLOR=BLACK I=JOIN VALUE=CIRCLE; SYMBOL2 COLOR=BLACK I=JOIN VALUE=SQUARE; SYMBOL3 COLOR=BLACK I=JOIN VALUE=TRIANGLE; LEGEND1 FRAME LABEL=("Origin of Car"); TITLE2 "Example Error Bar Plot Using Annotate"; PROC GPLOT DATA=summary; PLOT mean * engine = origin / HAXIS=AXIS1 VAXIS=AXIS2 LEGEND=LEGEND1 ANNOTATE=anno; RUN;QUIT; Create summary data using PROC MEANS Offset the x-axis values to ensure that the plotted symbols do not overwrite each other a common device used to “fool” SAS/Graph DATA summary; SET summary; IF UPCASE(origin) EQ 'ASIA' THEN engine = engine-0.1; IF UPCASE(origin) EQ 'USA' THEN engine = engine+0.1; RUN;

Common Tasks – GTL The scatter plot plots the mean values as well as the “error” bars (the same data is used, offsetting the X axis values) The EVAL functions are performing the same calculation as in the annotate macros previously The series plot is overlaid to apply the joined mean points ScatterPlot X=engine Y=mean / GROUP=origin NAME="scatter" YErrorLower=EVAL(mean-stddev) YErrorUpper=EVAL(mean+stddev);   SeriesPlot X=engine Y=mean / GROUP=origin; DiscreteLegend "scatter" / ACROSS=3 TITLE="Origin of Car"; EndLayout; EndGraph; END; RUN; PROC SGRENDER DATA=summary TEMPLATE=errorbar; PROC TEMPLATE; DEFINE STATGRAPH errorbar; BeginGraph; EntryTitle "PhUSE 2010"; The UNICODE statement inserts ± into the title line EntryTitle "Example Error Bar (Mean " {UNICODE '00B1'X} " SD) Plot Using GTL"; Layout OVERLAY / XAxisOpts=(LABEL="Engine Size") YAxisOpts=(LABEL="Mean Horsepower");  

Multiple Plots On One Page - Traditional Again, SAS/Graph needs to be manipulated into achieving the results we want: Produce plots and send to a graphics catalog [GRAPHT] GOPTIONS NODISPLAY; PROC GPLOT DATA=cars GOUT=grapht; TITLE1 "#BYVAL(ORIGIN)"; BY origin; PLOT mpg_highway * horsepower = type / HAXIS=AXIS1 VAXIS=AXIS2; RUN;QUIT;  

Multiple Plots On One Page - Traditional Again, SAS/Graph needs to be manipulated into achieving the results we want: Produce plots and send to a graphics catalog [GRAPHT] Produce a title and footnote output using GSLIDE and send to a graphics catalog [GRAPHT] PROC GSLIDE GOUT=grapht; TITLE1 "PhUSE 2010"; TITLE2 "Multiple Plots Using PROC GREPLAY"; RUN;QUIT; TITLE;

Multiple Plots On One Page - Traditional Again, SAS/Graph needs to be manipulated into achieving the results we want: Produce plots and send to a graphics catalog [GRAPHT] Produce a title and footnote output using GSLIDE and send to a graphics catalog [GRAPHT] Produce a replay template and store in a template catalog [TEMPCAT] PROC GREPLAY TC=tempcat NOFS; TDEF fourGS DES='Four Plots + GSLIDE' 1 / LLX=0 LLY=50 ULX=0 ULY=94 LRX=50 LRY=50 URX=50 URY=94 2 / LLX=50 LLY=50 ULX=50 ULY=94 LRX=100 LRY=50 URX=100 URY=94 3 / LLX=0 LLY=6 ULX=0 ULY=50 LRX=50 LRY=6 URX=50 URY=50 4 / LLX=50 LLY=6 ULX=50 ULY=50 LRX=100 LRY=6 URX=100 URY=50 5 / DEF; TEMPLATE fourGS; LIST TEMPLATE; RUN; QUIT;  

Multiple Plots On One Page - Traditional Again, SAS/Graph needs to be manipulated into achieving the results we want: Produce plots and send to a graphics catalog [GRAPHT] Produce a title and footnote output using GSLIDE and send to a graphics catalog [GRAPHT] Produce a replay template and store in a template catalog [TEMPCAT] Replay plots and slide into previously designed template using GREPLAY PROC GREPLAY IGOUT=grapht GOUT=grapht TC=tempcat NOFS; LIST IGOUT; TEMPLATE=fourGS; TREPLAY 1: gplot1 2: gplot2 3: gplot3 5: gslide ; RUN; QUIT;

Multiple Plots On One Page – GTL Multiple plots on page are far easier to achieve using GTL compared to traditional coding Titles are defined for the entire graph after the BEGINGRAPH statement PROC TEMPLATE; DEFINE STATGRAPH layoutdatapanel; BeginGraph; EntryTitle "PhUSE 2010"; EntryTitle "Multiple Plots Using GTL"; EndGraph; END; RUN;

Multiple Plots On One Page – GTL Multiple plots on page are far easier to achieve using GTL compared to traditional coding Titles are defined for the entire graph after the BEGINGRAPH statement Define number of panels required (2 x 2) RowDataRange ensures that the same axis range is used HeaderLabelDisplay ensures individual graph headings are produced PROC TEMPLATE; DEFINE STATGRAPH layoutdatapanel; BeginGraph; EntryTitle "PhUSE 2010"; EntryTitle "Multiple Plots Using GTL"; Layout DataPanel ClassVars=(origin) / COLUMNS=2 ROWS=2 RowDataRange=UNIONALL HeaderLabelDisplay=VALUE; EndLayout; EndGraph; END; RUN;

Multiple Plots On One Page – GTL Multiple plots on page are far easier to achieve using GTL compared to traditional coding Titles are defined for the entire graph after the BEGINGRAPH statement Define number of panels required (2 x 2) Layout PROTOTYPE builds a composite of plot statements This repeats for each cell defined in a parent DATAPANEL statement PROC TEMPLATE; DEFINE STATGRAPH layoutdatapanel; BeginGraph; EntryTitle "PhUSE 2010"; EntryTitle "Multiple Plots Using GTL"; Layout DataPanel ClassVars=(origin) / COLUMNS=2 ROWS=2 RowDataRange=UNIONALL HeaderLabelDisplay=VALUE; Layout Prototype / CycleAttrs=TRUE; ScatterPlot X=horsepower Y=mpg_highway / GROUP=type NAME="scatter"; EndLayout; EndGraph; END; RUN; Parent Child

Multiple Plots On One Page – GTL Multiple plots on page are far easier to achieve using GTL compared to traditional coding Titles are defined for the entire graph after the BEGINGRAPH statement Define number of panels required (2 x 2) Layout PROTOTYPE builds a composite of plot statements Use the SIDEBAR statement to define a legend for the entire DATAPANEL PROC TEMPLATE; DEFINE STATGRAPH layoutdatapanel; BeginGraph; EntryTitle "PhUSE 2010"; EntryTitle "Multiple Plots Using GTL"; Layout DataPanel ClassVars=(origin) / COLUMNS=2 ROWS=2 RowDataRange=UNIONALL HeaderLabelDisplay=VALUE; Layout Prototype / CycleAttrs=TRUE; ScatterPlot X=horsepower Y=mpg_highway / GROUP=type NAME="scatter"; EndLayout; Sidebar; DiscreteLegend "scatter" / TITLE="Type of Car"; EndSidebar; EndGraph; END; RUN;

Dynamic Templates Dynamic templates are analogous to macros The same basic graph is being produced but the programmer can alter the input variables MVAR defines macro variables used in the template Note how the macro variables are not referenced using & DYNAMIC defines variables that the user can define at run-time dependent on the input data set PROC TEMPLATE; DEFINE STATGRAPH scatter_dyn; BeginGraph; MVar SysDate9 SysTime; Dynamic XVar YVar GrpVar; EntryTitle "PhUSE 2010"; EntryTitle "Example GTL Using Dynamic Variables"; EntryTitle "Group Variable = " GrpVar; EntryFootnote HAlign=LEFT "DateTime: " SysDate9 ":" SysTime; EndGraph; END; RUN;

Dynamic Templates Dynamic templates are analogous to macros The same basic graph is being produced but the programmer can alter the input variables MVAR defines macro variables used in the template DYNAMIC defines variables that the user can define at run-time dependent on the input data set The dynamic variables have been used instead of static pre-defined variables in the scatter plot and title PROC TEMPLATE; DEFINE STATGRAPH scatter_dyn; BeginGraph; MVar SysDate9 SysTime; Dynamic XVar YVar GrpVar; EntryTitle "PhUSE 2010"; EntryTitle "Example GTL Using Dynamic Variables"; EntryTitle "Group Variable = " GrpVar; EntryFootnote HAlign=LEFT "DateTime: " SysDate9 ":" SysTime; Layout OVERLAY; ScatterPlot X=XVar Y=YVar / GROUP=GrpVar NAME="scatter"; DiscreteLegend "scatter"; EndLayout; EndGraph; END; RUN;

Dynamic Templates Dynamic templates are analogous to macros The same basic graph is being produced but the programmer can alter the input variables MVAR defines macro variables used in the template DYNAMIC defines variables that the user can define at run-time dependent on the input data set The dynamic variables have been used instead of static pre-defined variables in the scatter plot and title Using PROC SGRENDER with the same data set [CARS], referencing the previously defined template [SCATTER_DYN], the DYNAMIC statement is used to produce 2 different plots by specifying a different GRPVAR Note that variables are referenced within “” PROC SGRENDER DATA=cars TEMPLATE=scatter_dyn; DYNAMIC XVAR="horsepower" YVAR="mpg_highway" GRPVAR="origin"; RUN; DYNAMIC XVAR="horsepower" YVAR="mpg_highway" GRPVAR="type";

ODS Graphics ODS GRAPHICS uses pre-defined GTL templates (these can be modified by the user if required) to produce statistical model checking output It’s available for a wide range of SAS/STAT procedures and is easy to invoke ODS GRAPHICS ON; PROC REG DATA=cars; MODEL horsepower = enginesize; RUN; QUIT; ODS GRAPHICS OFF;

Conclusion The addition of GTL has brought some exciting new tools to the SAS/Graph programmer’s armoury. Traditional SAS/Graph will always have its place, especially with the extremely useful and versatile annotate system, but the addition of GTL to SAS/Graph means that programmers have gained some powerful and efficient graphics creation tools.   GTL is a different way of programming graphs but it can be used to produce some outputs that previously took many lines of code.  GTL can be used to produce dynamic multiple-plot displays efficiently and quickly that would previously take many procedures, data steps and some fairly complex macros. GTL is a fairly recent introduction to the SAS/Graph programming environment and most of us have only scratched the surface of what can be accomplished with GTL

Questions/Contact Details Your comments and questions are valued and encouraged. Contact the author at: Lawrence Heaton-Wright Quintiles Limited Station House, Market Street Bracknell, Berkshire, RG12 1HX United Kingdom Phone: +44 1344 708320, Fax: +44 1344 708106 Email: lawrence.heaton-wright@quintiles.com Web: www.quintiles.com