Introduction to SAS ODS Graphics September 16, 2015 Rocio Lopez.

Slides:



Advertisements
Similar presentations
1 SESSION 5 Graphs for data analysis. 2 Objectives To be able to use STATA to produce exploratory and presentation graphs In particular Bar Charts Histograms.
Advertisements

Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
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.
Converting SAS/GRAPH to ODS Graphics
Excel Tutorial 4: Enhancing a Workbook with Charts and Graphs
® Microsoft Office 2010 Excel Tutorial 4: Enhancing a Workbook with Charts and Graphs.
FIRST COURSE Excel Tutorial 4 Working with Charts and Graphics.
What is New in SAS 9.2? Graphics and More. A Brief History of SAS Graphics 6.x 7.x = had the Output Delivery System (ODS) but it was not widely available.
Using Cascading Style Sheets CSS Basics. Goals Understand basic syntax of Cascading Style Sheets (CSS) Understand basic syntax of Cascading Style Sheets.
Descriptive Statistics In SAS Exploring Your Data.
Charts and Macros Pretty Pictures. Charts Graphical display of information Often referred to as “Visualization” Allows a more innate grasp of numeric.
A Strip Plot Gets Jittered into a Beeswarm by Shane Rosanbalm.
COMPREHENSIVE Excel Tutorial 4 Working with Charts and Graphics.
1 Computing for Todays Lecture 10 Yumei Huo Fall 2006.
SW318 Social Work Statistics Slide 1 Using SPSS for Graphic Presentation  Various Graphics in SPSS  Pie chart  Bar chart  Histogram  Area chart 
Copyright © 2007, SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks.
XP New Perspectives on Microsoft Office Excel 2003 Tutorial 4 1 Microsoft Office Excel 2003 Tutorial 4 – Working With Charts and Graphics.
Introduction to SPSS (For SPSS Version 16.0)
ADVANCED MICROSOFT POWERPOINT Lesson 6 – Creating Tables and Charts
The gchart Procedure The gchart Procedure is used to create bar charts of various types (it can also create pie charts. It’s most basic form would look.
Instructor: Professor Cora Martinez, PhD Department of Civil and Environmental Engineering Florida International University.
CMPF 112 : COMPUTING SKILLS FOR ENGINEERS MICROSOFT OFFICE SUITE: EXCEL.
Copyright © 2008, SAS Institute Inc. All rights reserved. SAS Graphics on ODS v9.2 Performance Enhancing Steroids Daniel O’Connor Systems Developer, SAS.
Graphical Reporting of Clinical Trial Data with SAS ODS Graphics
Introduction to SAS Essentials Mastering SAS for Data Analytics
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,
C51BR Applications of Spreadsheets 1 Chapter 16 Getting Started Making Charts.
STATISTICS Microsoft Excel “Frequency Distribution”
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Chapter 5: Charts Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
TS02 SAS GTL - Injecting New Life into Graphs
Copyright © 2008 SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks.
ODS Statistical Graphics in SAS 9.2 January 17, 2010.
A Picture Is Worth A Thousand Words. DAY 7: EXCEL CHAPTER 4 Tazin Afrin September 10,
Introduction to SAS/Graph 9.2 Ken Barz Colorado Prevention Center 22Oct2009 Ken Barz Colorado Prevention Center.
Advanced Stata Workshop FHSS Research Support Center.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
Copyright © 2008 Pearson Prentice Hall. All rights reserved Committed to Shaping the Next Generation of IT Experts. Chapter 5 Charts and Graphs Robert.
Lecture 3 Topic - Descriptive Procedures Programs 3-4 LSB 4:1-4.4; 4:9:4:11; 8:1-8:5; 5:1-5.2.
PowerPoint Lesson 6 Working with Tables and Charts Microsoft Office 2010 Advanced Cable / Morrison 1.
Mr. Magdi Morsi Statistician Department of Research and Studies, MOH
1. Tables, Charts, and Graphs Microsoft Word & Excel 2003.
1.Introduction to SPSS By: MHM. Nafas At HARDY ATI For HNDT Agriculture.
1 Statistical Software Programming. STAT 6360 –Statistical Software Programming SAS Graphics SAS has two main facilities for producing graphics: 1.ODS.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
#pharmasug About OMICS Group OMICS Group is an amalgamation of Open Access Publications and worldwide international science conferences and events. Established.
Chapter 8: Using Basic Statistical Procedures “33⅓% of the mice used in the experiment were cured by the test drug; 33⅓% of the test population were unaffected.
SAS/GRAPH The Basics. Today’s Topics GOPTIONS GPLOT GCHART GCONTOUR G3D.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
Creating Charts Ms. Hall Spring Using the Insert Tab to Create Charts The Insert tab contains the command groups you’ll use to create charts in.
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
SAS Graphical Macros February 17, 2016 Rocio Lopez.
SAS GTL. What we’re going to cover… Some basics Layouts Plots Examples.
ODS Graphics By Example March 16, 2016 Rocio Lopez.
ODS Graphics: Modifying Style Attributes October 21, 2015 Rocio Lopez.
Introduction to Graphing in SAS
Lesson 4 Descriptive Procedures
Tutorial 4: Enhancing a Workbook with Charts and Graphs
Lesson 3 Overview Descriptive Procedures Controlling SAS Output
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.
INTRODUCTION TO SGPLOT Zahir Raihan OVERVIEW  ODS Graphics  SGPLOT overview  Plot Content  High value plot statements  High value plot options 
Getting Started with the SGPLOT Procedure: A Hands-On Workshop About the Presenter 1/14/2019 Josh Horstman is an independent statistical programming consultant.
Click Headings Above to View Content
Clinical Graphs using SAS®
Presentation transcript:

Introduction to SAS ODS Graphics September 16, 2015 Rocio Lopez

Overview Introduction Basic Set-Up SAS Automatic Graphs SG Procedures – SGPlot – SGPanel – SGScatter Take away message Future Talks

INTRODUCTION

Introduction Until version 9 all graphics were done with SAS/GRAPH procedures (gplot, gchart, etc.)

Introduction ODS graphics – Developed to make it easier to generate common graphics. – Features: – Graphics capabilities added to statistical procedures – SG procedures – Graphics Template Language (GTL) – ODS Graphics Designer & Editor 9.3 and 9.4 (including maintenance releases) have made lots of improvements and additions

Some Examples

SET-UP

Set-up Request graphs ods graphics on; proc statements; ods graphics off; In SAS 9.4 ODS graphics are generated by default. Where to view graph – Results window – Depending on ods destination – stand alone figure – embedded figure in.rtf or.pdf file

Modifying destination and resolution

Modify graph options ods graphics ;

Modify graph options OptionDescription border|noborder border=on|off Control border around graph height=480px Height of graph. Accepted units are cm, in, mm, pct, pt, px. imagename="filename"Specify file name reset Reset all options to default values. To reset particular options use reset=option scale|noscale scale=on|off Specify whether the content of the graph is scaled proprotionally width=dimensionWidth of graph outputfmt=file-type Specify output format. This varies by ODS destination See User Guide for full list

Supported file types

Set-up – Recap ods listing gpath=“&GraphDir.” image_dpi=300; ods graphics / reset imagename=“Figure1” scale=on width=3in height=3in; proc statements; ods graphics off; Only need to resubmit these statements if you wish to change any of the options for next graph

AUTOMATIC GRAPHS

Automatic Graphs From Procedures Starting with SAS 9.2 many analytical procedures automatically generate certain graphs ods rtf file=“ProcRegExp.rtf” style=journal; ods graphics on; proc reg data=sashelp.class; model Weight = Height; run; ods graphics off; ods rtf close;

SGPLOT PROCEDURE

SGPLOT Procedure Single-cell graphs Supports over 20 different plot statements You can combine most plot statements in the same graph – Overlaid in order specified Supporting statements allow more customizations – Reference lines – Insets – Axes – Axes tables – Legends

SGPLOT Procedure - Syntax proc sgplot data= ; plot-statement(s) required-parameters ; ; run;

SGPLOT - Histogram proc sgplot data=sashelp.class; histogram age; run;

SGPLOT – Histogram & Density proc sgplot data=sashelp.class; histogram age; density age; run;

SGPLOT – Histogram (move legend) proc sgplot data=sashelp.class; histogram age; density age; keylegend / location=inside position=topright noborder; run;

SGPlot – Box Plot proc sgplot data=sashelp.class; hbox height/category=sex; run; proc sgplot data=class; vbox height/category=sex group=Over13; run;

SGPlot – Bar chart proc sgplot data=sashelp.cars; vbar type/stat=percent; run; proc sgplot data=sashelp.cars; hbar type/stat=percent; run;

SGPlot – Bar chart (add data label and change axis) proc sgplot data=sashelp.cars; vbar type/stat=percent datalabel; yaxis values=(0 to 0.6 by 0.1) max=0.65 valueshint; run; Specifies to ignore the values listed when determining min and max range

SGPLOT – Stacked Bar chart proc sgplot data=sashelp.cars; vbar type/stat=percent group=origin; run;

SG Procedure – Grouped Bar chart proc sgplot data=sashelp.cars; vbar type/stat=percent group=origin datalabel groupdisplay=cluster; run; Note: The %’s calculated are out of the total. If you want to show distribution of origin within type, for example, you would need to calculate first.

SGPlot – Grouped Bar chart proc freq data=sashelp.cars; tables type*origin; ods output CrossTabFreqs=Pct; run; proc sgplot data=Pct; vbar type/ group=origin groupdisplay=cluster response=RowPercent; yaxis label=“Percent”; run;

SGPlot – Axis Table proc sgplot data=Pct; vbar type/ group=origin groupdisplay=cluster response=RowPercent; xaxistable frequency/ title='Frequency'; keylegend /location=inside position=topright noborder; yaxis label=“Percent”; run;

Some Notes on Axis Tables Can be used with any kind of plot. For categorized charts the category and group variables from the chart are used automatically. For other plots you would need to specify. – xaxistable variable /x=xvariable class=groupvariable; You can specify more than one variable or include multiple xaxistable commands yaxistable also available

SGPLOT – Scatter Plots proc sgplot data=sashelp.class; scatter x=height y=weight/ group=sex; keylegend /location=inside position=topleft down=2; run;

SGPLOT – Easily Add Reference Lines proc sgplot data=sashelp.class; refline 100/axis=y; scatter x=height y=weight/ group=sex; keylegend /location=inside position=topleft down=2; run;

SGPLOT – Scatter Plots with Error Bars proc sgplot data=class_means; scatter x=sex y=wt_mean/ yerrorlower=wt_lclm yerrorupper=wt_uclm; yaxis label=“Mean Weight”; xaxis offsetmin=0.25 offsetmax=0.25; run;

SGPLOT – Series Plots proc sgplot data=sashelp.stocks; series x=date y=close/ group=stock; run; proc sgplot data=sashelp.stocks; series x=date y=close/group=stock curvelabel curvelabelpos=max; run;

SGPlot Now let’s create this plot with some of what we’ve learned so far.

SGPlot –Overlaying Plots proc sgplot data=sashelp.classfit noautolegend; band x=height upper=uppermean lower=lowermean/name='cl' legendlabel='95% Confidence Limits'; run;

SGPlot –Overlaying Plots proc sgplot data=sashelp.classfit noautolegend; band x=height upper=uppermean lower=lowermean/name='cl' legendlabel='95% Confidence Limits'; scatter x=height y=weight; run;

SGPlot –Overlaying Plots proc sgplot data=sashelp.classfit noautolegend; band x=height upper=uppermean lower=lowermean/name='cl' legendlabel='95% Confidence Limits'; scatter x=height y=weight; series x=height y=predict/ name='fit'; run;

SGPlot –Overlaying Plots proc sgplot data=sashelp.classfit noautolegend; band x=height upper=uppermean lower=lowermean/name='cl' legendlabel='95% Confidence Limits'; scatter x=height y=weight; series x=height y=predict/name='fit'; series x=height y=lower/ lineattrs=(pattern=dash) name='pl' ; series x=height y=upper/ lineattrs=(pattern=dash); run;

SGPlot –Overlaying Plots proc sgplot data=sashelp.classfit noautolegend; band x=height upper=uppermean lower=lowermean/name='cl' legendlabel='95% Confidence Limits'; scatter x=height y=weight; series x=height y=predict/name='fit'; series x=height y=lower/ lineattrs=(pattern=dash) name='pl' ; series x=height y=upper/ lineattrs=(pattern=dash); inset "R(*ESC*){sup '2'} = 0.77" "Adjusted R(*ESC*){sup '2'} = 0.76"; run;

SGPlot –Overlaying Plots proc sgplot data=sashelp.classfit noautolegend; band x=height upper=uppermean lower=lowermean/name='cl' legendlabel='95% Confidence Limits'; scatter x=height y=weight; series x=height y=predict/name='fit'; series x=height y=lower/ lineattrs=(pattern=dash) name='pl' ; series x=height y=upper/ lineattrs=(pattern=dash); inset "R(*ESC*){sup '2'} = 0.77" "Adjusted R(*ESC*){sup '2'} = 0.76"; keylegend 'fit' 'cl' 'pl'; run;

SGPLOT – Or just use the reg plot proc sgplot data=sashelp.class; reg x=height y=weight/cli clm; keylegend /across=3; run;

SGPANEL PROCEDURE

SGPANEL Procedure Classification panels – Same plot repeated by classification variable SGPLOT syntax carries over with some minor changes – xaxis is now colaxis – yaxis is now rowaxis

SGPANEL Procedure proc sgpanel data=cars_reduced; panelby type/novarname; scatter x=mpg_city y=horsepower; run;

SGPanel - Layout panelby type/ novarname columns=4; Or panelby type/ novarname layout=columnlattice; panelby type/ novarname rows=4; Or panelby type novarname/ layout=rowlattice;

SGPANEL Procedure – 2 Class Variables panelby type origin/ novarname; panelby type origin/ novarname layout=lattice;

SGSCATTER PROCEDURE

SGSCATTER Procedure Comparative scatter plots or scatter plot matrices Does not use layered architecture Supports 3 plot statements

SGScatter – Plot statement proc sgscatter data=sashelp.cars; plot (mpg_city mpg_highway)* horsepower; run;

SGScatter – Compare statement proc sgscatter data=sashelp.cars; compare y=(mpg_city mpg_highway) x=horsepower; run;

SGScatter – Matrix statement proc sgscatter data=sashelp.cars; matrix mpg_city mpg_highway horsepower enginesize weight length; run;

TAKE AWAY MESSAGE

Take away message SAS has made many advances in their graphics procedures ODS graphics are easy to use and produce high quality plots There are constant improvements and new features being added For primarily SAS users there is no longer a need to rely on R for generating plots

SAS Version All examples presented have been generated using SAS 9.4. Some of the code might not run in

Talk Materials All materials will soon be available on SharePoint (waiting for the page to be set up) For now you can find them at my SAS community user page

Good Resources Statistical Graphics Procedures by Example: Effective Graphs Using SAS – Sanjay Matange & Dan Heath Graphically Speaking Blog ( SAS Tips Sheets – ODS Graphics ODS Graphics – SG Procedures SG Procedures – SGPlot SGPlot – SGPanel SGPanel SAS SG Procedures Documentation

FUTURE TALKS

Future talks Modifying style attributes Introduction to Graph Template Language (GTL) Automatic ODS Graphics from SAS Procedures and How to Modify These Useful SAS Graphics Macros Step-by-step examples of some plots

QUESTIONS?

THANKS