Creating Statistical Graphics With ODS In SAS Software

2y ago
61 Views
2 Downloads
3.61 MB
104 Pages
Last View : 9d ago
Last Download : 3m ago
Upload by : Tripp Mcmullen
Transcription

Creating StatisticalGraphics withODS inSAS SoftwareWarren F. KuhfeldSAS Institute Inc.1ASA Conference on Statistical PracticeFebruary 22, 2014Copyright 2011, SAS Institute Inc. All rights reserved.It’s an Exciting Time to Use SAS!Graphs Are Everywhere!Copyright 2014, SAS Institute Inc. All rights reserved.21

Learning ObjectivesYou will learn how to: Request graphs created by statistical procedures Use the new SGPLOT, SGPANEL, SGSCATTER, andSGRENDER procedures to create customized graphs Access and manage your graphs for inclusion in webpages, papers, and presentations Modify graph styles Make immediate changes to your graphs using a pointand-click editor Make permanent changes to your graphs with templatechanges Specify other options related to ODS GraphicsCopyright 2014, SAS Institute Inc. All rights reserved.3ODS Graphics – The BasicsAll you need to know to make great default graphs is:ods graphics on;ods graphics on;proc glm data sashelp.class;model weight height;run;Copyright 2014, SAS Institute Inc. All rights reserved.42

PROC GLM Fit Plot5Copyright 2014, SAS Institute Inc. All rights reserved.Statistical ProceduresThat Support ODS Graphics in SAS 9.4Base SASSAS/STAT LMPOWERGLMSELECTICLIFETESTSAS/QC VPMODELPARETORELIABILITYSHEWHARTSAS/ETS FREQSURVEYLOGISTICODS Graphics is part of SAS/GRAPH software in SAS 9.2.ODS Graphics is part of Base SASsoftware in SAS 9.3 – SAS 9.4.Copyright 2013, SAS Institute Inc. All rights AS RiskDimensions DATATIMEIDTIMESERIESUCMVARMAXX1263

Outline Introduction: The basics of ODS Graphics One step beyond the basics Graph and Style Template Languages Templates and item stores Graph template modification Style template modification The SG procedures and the GTL ConclusionsCopyright 2014, SAS Institute Inc. All rights reserved.7One Step Beyond the Basics Request optional graphs Change the destination Change the graph style Make an editable graph Specify commonly used optionsCopyright 2014, SAS Institute Inc. All rights reserved.84

Optional Graphsods html;* Assume "ods graphics on" is still enabled;proc glm data sashelp.class plots all;model weight height;run;ods html close;Copyright 2014, SAS Institute Inc. All rights reserved.9Copyright 2014, SAS Institute Inc. All rights reserved.10Optional Graphs5

PLOTS Option Select all graphs: PLOTS ALL Exclude all graphs: PLOTS NONE Request specific graphs: PLOTS (list ) Select only specific graphs: PLOTS(ONLY) (list ) Other PLOTS options vary by procedure Documented in the Syntax section Usually with the PROC statement options Other PROC options can change the default graphsCopyright 2014, SAS Institute Inc. All rights reserved.11Some ODS DestinationsDestination ViewerGraphics File TypesHTMLPNG (default), GIF, JPEG, Web browser(Referenced from HTML.)RTFMicrosoft WordContained in RTF filePDFAdobe ReaderContained in PDF fileLISTINGText EditorPNG (default), GIF, JPEG, (Viewed independently fromtables and other graphs.)Copyright 2014, SAS Institute Inc. All rights reserved.126

Typically just use one.Changing the Destinationods listingods htmlods rtfods pdffile "glm.lst";file "glm.htm";file "glm.rtf";file "glm.pdf";Typically just use one.ods graphics on;proc glm data sashelp.class;model weight height;run;ods listing close;ods html close;ods rtf close;ods pdf close;In the SAS windowingenvironment: SAS 9.2: LISTING is openby default ODS Graphics isnot enabled The default styleis LISTING SAS 9.3 – SAS 9.4: HTML is open bydefault ODS Graphics isenabled by default The default HTMLstyle is HTMLBlueCopyright 2014, SAS Institute Inc. All rights reserved.13Recommended StylesStyleDescriptionHTMLBlueNew color style for 9.3, the 9.3 default for the SASwindowing environment and SAS/STAT documentation.PEARLNew SAS 9.3M2 color style, based on HTMLBlue, forPRINTER, PDF, RTF. White background; black andwhite tables; HTMLBlue colors for graphs.SAPPHIRENew SAS 9.3M2 color style, based on HTMLBlue, forPRINTER, PDF, RTF. White background; blue, blackand white tables; HTMLBlue colors for graphs.JOURNALGray scale for black-and-white publications.JOURNAL2Pure black-and-white for publications.JOURNAL3Gray scale for black-and-white publications with mix ofgray scale and shading in bars.JOURNAL1A - JOURNAL – JOURNAL3 but with fonts from PEARL &JOURNAL3A SAPPHIRE. New at SAS 9.3M2.Copyright 2014, SAS Institute Inc. All rights reserved.147

Typically just use one.Typically just use one.Setting the Styleods html style HTMLBlue;ods pdf style Pearl;* Assume "ods graphics on" is still enabled;proc glm data sashelp.class plots all;model weight height;run;ods html close;ods pdf close;15Copyright 2014, SAS Institute Inc. All rights reserved.HTML with the HTMLBlue StyleNumber of Observations ReadNumber of Observations UsedSourceModelErrorCorrected TotalDF11718Sum ofSquares7193.2491192142.4877239335.7368421919Mean Square F Value Pr F7193.24911957.08 .0001126.028690R-Square Coeff Var Root MSE Weight Mean0.770507 11.22330 11.22625100.0263Source DFType I SS Mean Square F Value Pr FHeight1 7193.249119 7193.24911957.08 .0001Source DF Type III SSHeight1 7193.249119ParameterInterceptHeightMean Square F Value7193.249119 57.08Pr F .0001StandardEstimateError t Value Pr t -143.0269184 32.27459130-4.43 0.00043.8990303 0.516093957.55 .0001Copyright 2014, SAS Institute Inc. All rights reserved.168

HTML with the HTMLBlue StyleCopyright 2014, SAS Institute Inc. All rights reserved.17PDF with the Pearl StyleCopyright 2014, SAS Institute Inc. All rights reserved.189

PDF with the Pearl StyleCopyright 2014, SAS Institute Inc. All rights reserved.19PDF with the Journal1a StyleCopyright 2014, SAS Institute Inc. All rights reserved.2010

Legacy StylesStyleDescriptionDEFAULTColor style intended for general-purpose work.This is the default for the HTML destination.STATISTICALColor style intended for output in Web pages or colorprint media.ANALYSISColor style with a somewhat different appearance fromSTATISTICAL.RTFUsed to produce graphs to insert into a Microsoft Worddocument or a Microsoft PowerPoint slide.LISTINGDefault style for the LISTING destination, similar toDEFAULT but with a white background.Copyright 2014, SAS Institute Inc. All rights reserved.21Copyright 2014, SAS Institute Inc. All rights reserved.2211

Two Ways to Modify Your GraphsGraph Template Changes ODS Graph EditorAppropriate forSAS programmer familiarwith the Graph TemplateLanguage (although manychanges require noprogramming expertise)Statistical end userApproachProgrammingPoint-and-clickType of ChangePersistentImmediateDurationWhenever program is rerun Current graph onlyApplicationBatch processing of graphs Papers, presentationsFile SavedModified graph templatePNG or SGECopyright 2013, SAS Institute Inc. All rights reserved.23Creating Editable Graphsods graphics on;ods listing style statistical sge on;proc robustreg data sasuser.growth plots (ddplot histogram);model GDP LFG GAP EQP NEQ / diagnostics leverage;run;ods listing sge off;LISTING destination is required in SAS 9.2.SGE ON enables editable graphs.Copyright 2014, SAS Institute Inc. All rights reserved.2412

Accessing the ODS Graphics Editoricon for image fileicon for editable fileCopyright 2014, SAS Institute Inc. All rights reserved.25Diagnostic PlotBefore and During EditingCopyright 2014, SAS Institute Inc. All rights reserved.2613

Commonly Used Options ods graphics / width 6in; ods graphics / height 4in; ods graphics / antialias onantialiasmax 10000;markers or lines ods graphics / imagemap on;tool tips, HTML ods graphics / reset index imagename "name ";name.png name1.png ods listingimage dpi 300;Default DPIListing: 100HTML: 100RTF: 200Copyright 2014, SAS Institute Inc. All rights reserved.27Commonly Used HTML Optionsods listing close;ods html path 'C:\temp' (url none) file 'test.html';ods graphics on;proc glm data sashelp.class plots all;model weight height;run;ods html close;ods listing; path provides the path where all files are written (url none) suboption creates links to graphs from theHTML file using just the file the names and no explicit path All files can all be moved together All links in the HTML file work after the files are moved file provides the name of the HTML fileCopyright 2014, SAS Institute Inc. All rights reserved.2814

Manage Graphs for Web Pages, Papers, andPresentations Copy from ODS HTML destination Copy from ODS RTF destination Save PNG files (ODS HTML or LISTING) SAS/STAT (and some other products) captures outputin ODS documents, replays them using PROCDOCUMENT (creating PNG files for graphs and TXTfiles for tables), and then includes them into LaTeX. ings12/324-2012.pdf(or search for "Arnold Statrep").Copyright 2014, SAS Institute Inc. All rights reserved.29ODS Graphics Overview Invoke withods graphics on; Procedure options specify which graphs you get ODS destination specifies where you see your graphs ODS styles control what all your graphs look like Style template is a program that sets colors, fonts, and overallappearance Graph template determines how a specific graph isconstructed Graph template is a SAS program written in the Graph TemplateLanguage (GTL) that provides instructions for creating the graphCopyright 2014, SAS Institute Inc. All rights reserved.3015

Graph and Style Templates Each graph and style has an ODS template A SAS program that provides instructions for creating thegraph or style SAS provides a template for every graph and style You do not need to know anything abouttemplates to create statistical graphics With just a little knowledge of the graph and styletemplate languages you can: Modify graph templates Modify style templates Make permanent changes that apply every time you run aprocedureCopyright 2014, SAS Institute Inc. All rights reserved.31Outline Introduction: The basics of ODS Graphics One step beyond the basics Graph and Style Template Languages Templates and item stores Graph template modification Style template modification The SG procedures and the GTL ConclusionsCopyright 2014, SAS Institute Inc. All rights reserved.3216

Determining Template NamesAssume that these Submit:are specified forods graphics on; the rest of thetalk.ods trace on;proc kde data sashelp.class;bivar height weight /plots scatter;run; Trace output in the SAS log:Name:Label:Template:Path:ScatterPlotScatter PlotStat.KDE.Graphics.ScatterPlotKDE.Bivar1.Height Weight.ScatterPlotCopyright 2014, SAS Institute Inc. All rights reserved.33Displaying Template Source CodeSubmit:proc template;source Stat.KDE.Graphics.ScatterPlot;run;define statgraph Stat.KDE.Graphics.ScatterPlot;dynamic VAR1NAME VAR1LABEL VAR2NAME VAR2LABEL;BeginGraph;EntryTitle "Distribution of " VAR1NAME " by " VAR2NAME;layout Overlay / xaxisopts (offsetmin 0.05 offsetmax 0.05)yaxisopts (offsetmin 0.05 offsetmax 0.05);ScatterPlot x X y Y / markerattrs GRAPHDATADEFAULT;EndLayout;This is displayed in the SAS log,EndGraph;and you have to copy and pasteend;it into your editor.Copyright 2014, SAS Institute Inc. All rights reserved.3417

ODS Graphics OverviewsashelpItemstoreDirect connectionbetween data setand data objectTemplates that you modifiedItemstoreODSSASdata setPROCKDEsasuserTemplates that SAS ationPLOTS optionYou can control the graph and style template.You cannot control the data object or make theprocedure output information that it was notoriginally intended to output.ODS Graphics EditorNew graph35Copyright 2014, SAS Institute Inc. All rights reserved.ODS Graphics OverviewsashelpItemstoreNo connectionbetween data setand data objectSASdata setPROCFACTORPLOTS aphtemplateDestinationYou can control the graph and style template.You cannot control the data object or make theprocedure output information that it was notoriginally intended to output.Copyright 2014, SAS Institute Inc. All rights reserved.ODS Graphics EditorNew graph3618

Submitting Template Code to SASproc template;define statgraph Stat.KDE.Graphics.ScatterPlot;dynamic VAR1NAME VAR1LABEL VAR2NAME VAR2LABEL;BeginGraph;EntryTitle "Distribution of " VAR1NAME " by " VAR2NAME;layout Overlay / xaxisopts (offsetmin 0.05 offsetmax 0.05)yaxisopts (offsetmin 0.05 offsetmax 0.05);ScatterPlot x X y Y / markerattrs GRAPHDATADEFAULT;EndLayout;EndGraph;end;run;You can easily change the title witha minimal understanding of thegraph template language (GTL).Copyright 2014, SAS Institute Inc. All rights reserved.37SAS Libraries for Storing Templates ODS PATH statement specifies where compiledtemplates are stored: SASUSER (default) library where they arepermanently available until you delete them WORK library is deleted at the end of your SASsession Permanent library that you name and createfor you or others to useThe locations are the same as with SAS data sets(but with a different default)Copyright 2014, SAS Institute Inc. All rights reserved.3819

Default ODS PathSubmit:ods path show;Current ODS PATH list is:1. SASUSER.TEMPLAT(UPDATE)2. SASHELP.TMPLMST(READ)By default, templates that yousubmit to SAS go here.The templates that SASprovides are here.When retrieving templates,SAS first looks inSASUSER.TEMPLAT and then inSASHELP.TMPLMST.39Copyright 2014, SAS Institute Inc. All rights reserved.Modifying the Default Path andCreating a Temporary Template Item StoreSubmit:ods path .tmplmst(read);ods path (prepend) work.templat(update);ods path show;Current ODS PATH list is:1. WORK.TEMPLAT(UPDATE)2. SASUSER.TEMPLAT(UPDATE)3. SASHELP.TMPLMST(READ)Copyright 2014, SAS Institute Inc. All rights reserved.These areequivalent.You justneed one.Note: The ODSPATH statementapplies only tothe current SASsession or untilyou change it.4020

Modifying the Default Path andCreating a Permanent Template Item StoreSubmit:ods path sasuser.templat(update)sashelp.tmplmst(read);ods path reset;Reset to the defaultpath if you previouslymodified it. Theseare equivalent. Youjust need one.libname mytpl 'C:\MyTemplateLibrary';ods path (prepend) mytpl.templat(update);ods path show;Current ODS PATH list is:1. MYTPL.TEMPLAT(UPDATE)2. SASUSER.TEMPLAT(UPDATE)3. SASHELP.TMPLMST(READ)Copyright 2014, SAS Institute Inc. All rights reserved.Tip: With this approach,you get the SAS defaulttemplates by default andyour modified templatesonly when you specificallyrequest them by modifyingthe path.41Best Practices: Clean Up Delete templates individually:proc template;delete Stat.KDE.Graphics.ScatterPlot;run; Delete the SASUSER.TEMPLAT item store:ods path sashelp.tmplmst(read);The library must notproc datasets library sasuser;be in the path whenit is deleted.delete templat(memtype itemstor);run; quit;ods path reset; Tip: If you store templates in a library other than Sasuser,deletion is less of an issue:libname mytpl 'C:\MyTemplateLibrary';ods path (prepend) mytpl.templat(update);Copyright 2014, SAS Institute Inc. All rights reserved.4221

Outline Introduction: The basics of ODS Graphics One step beyond the basics Graph and Style Template Languages Templates and item stores Graph template modification Style template modification The SG procedures and the GTL ConclusionsCopyright 2014, SAS Institute Inc. All rights reserved.43Ways to Modify a Graph Consult the documentation. You might just need tospecify the right options. Use the ODS Graphics Editor to make minor one-timechanges Use an SG procedure such as PROC SGPLOT to makea graph from an output data set Modify the graph template Write your own template and use PROC SGRENDER Tip: You can: Tip: You cannot: Add new templates Modify existing templates Change template names Add or change options Add new dynamic variables Add new macro variablesCopyright 2014, SAS Institute Inc. All rights reserved.4422

Changing Titles, Ticks, Axis Labels, and GridsBeforeAfterCopyright 2014, SAS Institute Inc. All rights reserved.45Displaying the Template Submit:proc factor data sashelp.cars plots(unpack) scree;run; PROC FACTOR trace output:Name:Label:Template:Path:ScreePlotScree olution.ScreeAndVarExp.ScreePlot Submit:proc template;source Stat.Factor.Graphics.ScreePlot1;run;Copyright 2014, SAS Institute Inc. All rights reserved.4623

Changing Titles, Ticks, Axis Labels, & Gridsdefine statgraph Stat.Factor.Graphics.ScreePlot1;notes "Scree Plot for Extracted Eigenvalues";BeginGraph / designwidth DefaultDesignHeight;Entrytitle "Scree Plot" / border false;layout overlay / yaxisopts (label "Eigenvalue" gridDisplay auto on)xaxisopts (label "Factor" linearopts (integer true));Design Width640 x 640Design HeightDesign Width360 px480 x480Design Width480 x 640Design Heightendlayout;EndGraph;end;Design Heightseriesplot y EIGENVALUE x NUMBER / display ALL;360 x 640Design Width47Copyright 2014, SAS Institute Inc. All rights reserved.Changing Titles, Ticks, Axis Labels, & Gridsproc template;define statgraph Stat.Factor.Graphics.ScreePlot1;notes "Scree Plot for Extracted Eigenvalues";BeginGraph / designwidth DefaultDesignHeight;Entrytitle "Eigenvalue ((*ESC*){Unicode Lambda}) Plot"; /* border false*/layout overlay /yaxisopts (label "(*ESC*){Unicode Lambda}") /* gridDisplay auto on */xaxisopts (label "Factor Number"linearopts (tickvaluelist (1 2 3 4 5 6 7 8 9 10)));seriesplot y EIGENVALUE x NUMBER /display ALL;endlayout;EndGraph;end;run;Note: Lambda u makes Λ.Copyright 2014, SAS Institute Inc. All rights reserved.4824

Intermission49Copyright 2014, SAS Institute Inc. All rights reserved.Default and Modified Box Plot%let DateTag Acme 01Apr2008;%let MyLabel Gender;proc glimmix data sashelp.class plots boxplot;class sex;model height sex;run;BeforeAfterCopyright 2014, SAS Institute Inc. All rights reserved.5025

Displaying the Template Submit:proc glimmix data sashelp.class plots boxplot;class sex;model height sex;run; PROC GLIMMIX trace output:Name:BoxPlotLabel:Residuals by SexTemplate: .BoxPlot Submit:proc template;source Stat.Glimmix.Graphics.BoxPlot;run;Copyright 2014, SAS Institute Inc. All rights reserved.51GLIMMIX Box Plot Templatedefine statgraph Stat.Glimmix.Graphics.BoxPlot;dynamic TITLE YVAR SHORTYLABEL;BeginGraph;entrytitle TITLE;layout overlay / yaxisopts (gridDisplay auto onshortlabel SHORTYLABEL)xaxisopts (discreteopts (tickvaluefitpolicy rotatethin));boxplot y YVAR x LEVEL / labelfar ondatalabel OUTLABEL primary true freq FREQ;endlayout;EndGraph;end;Notes: Title – specified with dynamic X axis label – not specified Y axis label – not specified,although a short label is specifiedCopyright 2014, SAS Institute Inc. All rights reserved.5226

Axis Labels Axis labels can be specified: Explicitly in the template with a literal string» label "Factor" Explicitly in the template through a dynamic variable» Label VARLABEL Implicitly through the data object labels and names The axis label comes from the first source that providesa value: LABEL option in the template Data object column label Data object column name Axes can have labels (e.g., “Cubic Clustering Criterion”or “Probability Density”) and optionally short labels forsmall plots (e.g., “CCC” or “Density”)Copyright 2014, SAS Institute Inc. All rights reserved.53Examining the Graph Data Object A graph (or table) is produced by applying a template tothe information in a SAS data object You can understand the data object columns by makinga SAS data set and examining the data set variables:proc glimmix data sashelp.class plots boxplot;class sex;ods output boxplot bp;model height sex;run;proc print;run;proc contents p;ods select position;run;/* display the variables in position order */Copyright 2014, SAS Institute Inc. All rights reserved.5427

Columns of the Data ObjectConstructed by ODS GraphicsProvided by ProcedureBOX YVAR X BOX YVAR X BOX YVAR X BOX YVAR TALABELO YO STO XO AXMEANSTDNFFFFFFFFMMMMMMMM.no labellabel OutLabel2347811121314156910151655Copyright 2014, SAS Institute Inc. All rights reserved.Column Names and Column LabelsThe CONTENTS ProcedureVariables in Creation Order# VariableType Len Format Label1 BOX YVAR X LEVEL DATALABEL O Y2 BOX YVAR X LEVEL DATALABEL O ST3 BOX YVAR X LEVEL DATALABEL O X4 BOX YVAR X LEVEL DATALABEL O DL5 Residual6 Level7 OutLabelNum 8Char 10Char 1Num 8Num 8Char 1Num 8ResidualSexBEST8. IndexSexBEST8. IndexThe name of the Y axis variable.(No label for the Y axis variable.)The label of the X axis variable.Copyright 2014, SAS Institute Inc. All rights reserved.5628

Tip: Displaying Values ofDynamic Variablesproc template;define statgraph Stat.Glimmix.Graphics.BoxPlot;dynamic TITLE YVAR SHORTYLABEL;BeginGraph;entrytitle TITLE;entrytitle "exists? " eval(exists( yvar)) " yvar: " yvar;entrytitle "exists? " eval(exists( shortylabel))" shortylabel: " shortylabel;layout overlay / yaxisopts (gridDisplay auto onshortlabel SHORTYLABEL)xaxisopts (discreteopts (tickvaluefitpolicy rotatethin));boxplot y YVAR x LEVEL / labelfar on datalabel OUTLABELprimary true freq FREQ;endlayout;EndGraph;end;proc glimmix data sashelp.class plots boxplot;class sex;ods output boxplot bp;model height sex;run;57Copyright 2014, SAS Institute Inc. All rights reserved.Titles, Axis Labels, Dynamic Variables, andMacro Variablesproc template;define statgraph Stat.Glimmix.Graphics.BoxPlot;dynamic TITLE YVAR SHORTYLABEL;mvar datetag mylabel;BeginGraph;entrytitle datetag " -- " TITLE;layout overlay / yaxisopts (label titlegridDisplay auto on shortlabel SHORTYLABEL)xaxisopts (label mylabeldiscreteopts (tickvaluefitpolicy rotatethin));boxplot y YVARx LEVEL /labelfar ondatalabel OUTLABELprimary truefreq FREQ;endlayout;EndGraph;end;run;Copyright 2014, SAS Institute Inc. All rights reserved.The names ofthe macrovariables areevaluatedwhen theanalyticalprocedureis run.Do not use anampersand.You can useentrytitle“&datetag --”TITLE;for templatecompile timeevaluation.5829

Using Macro Variables%let DateTag Acme 01Apr2008;%let MyLabel Gender;proc glimmixdata sashelp.classplots boxplot;class sex;model height sex;run;Copyright 2014, SAS Institute Inc. All rights reserved.59PROC LIFETEST Survival PlotRevised templates are available that make it easier to modifythis graph.SAS/STAT 12.1: emplt.pdfGlobal Forum: -2013.pdfSAS/STAT 13.1 aplan.pdfCopyright 2014, SAS Institute Inc. All rights reserved.6030

Outline Introduction: The basics of ODS Graphics One step beyond the basics Graph and Style Template Languages Templates and item stores Graph template modification Style template modification The SG procedures and the GTL Conclusions61Copyright 2014, SAS Institute Inc. All rights reserved.Style Modification The STATISTICAL style:proc template;source styles.statistical;source styles.default;run; A small portion of the results:'gcdata' cx445694'gdata' cxCAD5E5;class GraphDataDefault /.markersize 7pxmarkersymbol "circle"linethickness 1pxlinestyle 1contrastcolor GraphColors('gcdata')color GraphColors('gdata');From STATISTICALFrom DEFAULTMarker size ― 7 pixelsMarker type ― circleLine thickness ― 1 pixelLine style ― solidContrast color for markers, linesColor for filled areasCopyright 2014, SAS Institute Inc. All rights reserved.6231

Style Modificationproc template;define style Styles.MyStyle;parent Styles.Statistical;class GraphDataDefault /endcolor GraphColors('gramp3cend')neutralcolor GraphColors('gramp3cneutral')startcolor GraphColors('gramp3cstart')markersize 7pxmarkersymbol "square"linethickness 1pxlinestyle 1contrastcolor bluecolor GraphColors('gdata');end;run;63Copyright 2014, SAS Institute Inc. All rights reserved.Style ModificationNotice that the fitfunction color does notchange. It is controlledby the GraphFit styleelement.ods listing style MyStyle;proc transreg data sashelp.class;model identity(weight) spline(height);run;BeforeCopyright 2014, SAS Institute Inc. All rights reserved.After6432

Outline Introduction: The basics of ODS Graphics One step beyond the basics Graph and Style Template Languages Templates and item stores Graph template modification Style template modification The SG procedures and the GTL ConclusionsCopyright 2014, SAS Institute Inc. All rights reserved.65Graph Template LanguageThe GTL (graph template language) provides a powerfulsyntax for creating custom graphs Modify the templates that SAS provides for use with SASprocedures Use with PROC TEMPLATE and PROC SGRENDERproc template;define statgraph ClassScatter;. . .end;run;proc sgrender data sashelp.class template ClassScatter;run;Copyright 2014, SAS Institute Inc. All rights reserved.6633

Statistical Graphics Procedures The SG procedures:SGPLOT SGPLOT creates one or more graphs andoverlays them on a single set of axes SGSCATTER creates scatter plot matricesand panels of scatter plots for multiplecombinations of variablesSGSCATTER SGPANEL creates a panel of graphs for thevalues of one or more classification variables Provide a simple and convenient syntax forproducing many types of statistical graphs Convenient for exploring and presenting dataSGPANELPROC SGRENDER is a utility procedure used with the GTL;it is not considered to be one of the SG procedures.Copyright 2014, SAS Institute Inc. All rights reserved.67Copyright 2014, SAS Institute Inc. All rights reserved.68Scatter Plot34

proc sgplot data sashelp.class;title 'Weight by Height';scatter y weight x height;run;proc template;define statgraph ClassScatter;begingraph;entrytitle 'Weight by Height';layout overlay;scatterplot y weight x height;endlayout;endgraph;end;run;proc sgrenderdata sashelp.classtemplate ClassScatter;run;Copyright 2014, SAS Institute Inc. All rights reserved.69SG Procedure Notes SG procedures DO use Standard TITLE, FOOTNOTE, BY, LABEL,FORMAT, and WHERE statements ODS GRAPHICS statement for image name, imagetype, and size ODS destination statement for output type (HTML,PDF, etc.), style, and DPI SG procedures DO NOT use the SAS/GRAPH AXIS,LEGEND, SYMBOL, PATTERN, or GOPTIONSstatements ODS Graphics has no connection to traditionaldevice-based GRSEG graphics infrastructureCopyright 2014, SAS Institute Inc. All rights reserved.7035

proc sgplot data sashelp.class;title 'Weight by Height';scatter y weight x height / datalabel namemarkerattrs (symbol circlefilled color black size 3px);xaxis offsetmin 0.05 offsetmax 0.05 label 'Class Height';yaxis offsetmin 0.05 offsetmax 0.05 label 'Class Weight'values (50 to 150 by 25);run;Copyright 2014, SAS Institute Inc. All rights reserved.71proc sgplot data sashelp.class;title 'Weight by Height';scatter y weight x height / datalabel namemarkerattrs (symbol circlefilled color black size 3px);xaxis offsetmin 0.05 offsetmax 0.05 label 'Class Height';yaxis offsetmin 0.05 offsetmax 0.05 label 'Class Weight'values (50 to 150 by 25);run;proc template;define statgraph ClassScatter;begingraph;entrytitle 'Weight by Height';layout overlay /xaxisopts (offsetmin 0.05 offsetmax 0.05 label 'Class Height')yaxisopts (offsetmin 0.05 offsetmax 0.05 label 'Class Weight'linearopts (tickvaluesequence (start 50 end 150increment 25) viewmin 50));scatterplot y weight x height / datalabel namemarkerattrs (symbol circlefilled color black size 3px);endlayout;endgraph;end;run;proc sgrender data sashelp.class template ClassScatter; run;Copyright 2014, SAS Institute Inc. All rights reserved.7236

proc sgplot data sashelp.class tmplout ‘scatter.sas’;title 'Weight by Height';scatter y weight x height / datalabel namemarkerattrs (symbol circlefilled color black size 3px);xaxis offsetmin 0.05 offsetmax 0.05 label 'Class Height';yaxis offsetmin 0.05 offsetmax 0.05 label 'Class Weight'values (50 to 150 by 25);run;proc template;define statgraph sgplot;begingraph /;EntryTitle "Weight by Height" /;layout overlay / xaxisopts ( Label "Class Height" offsetmin 0.05 offsetmax 0.05type linear ) yaxisopts ( Label "Class Weight" offsetmin 0.05 offsetmax 0.05type linear linearopts ( tickvaluelist ( 50 75 100 125 150 ) viewmin 50 viewmax 150 ) );ScatterPlot X Height Y Weight / primary true Markerattrs ( Color CX000000Symbol CIRCLEFILLED Size 3px) DataLabel Name LegendLabel "Weight"NAME "SCATTER";endlayout;endgraph;end;run;Copyright 2014, SAS Institute Inc. All rights reserved.73Graph DesignerGraph designer is experimental in SAS 9.2 and production in 9.39.2: %sgdesign;9.3: Tools ODS Graphics DesignerPoint, click,and drag tomake graphsand graphtemplates.Copyright 2014, SAS Institute Inc. All

Style template is a program that sets colors, fonts, and overall appearance Graph template determines how a specific graph is constructed Graph template is a SAS program written in the Graph Template Language (GTL) that provi

Related Documents:

ODS Graphics works differently from SAS/GRAPH procedures. ODS Graphics output goes to open ODS destinations like HTML and PDF. ODS Graphics produces output in industry standard formats like PNG, PDF, SVG and many more. ODS Graphics produces high resolution graphs. Setting high DPI scales all aspects of the graph, including marker size and line .

SAS Output Delivery System (ODS) Graphics started appearing in SAS 9.2. Collectively these new tools were referred to as "ODS Graphics," "SG Graphics" and "Statistical Graphics". When first starting to use these tools, the traditional SAS/GRAPH software user might come upon some very significant

What's New in SAS ODS Graphics This session explores the new graphical capabilities available directly from many existing SAS procedures and the new SG procedures. Also, learn more about what's new in ODS Graphics, including the ODS Graphics Designer, the ODS Graphics Editor, and the Graph Template Language. Updated to include 9.3 changes.

Paper SAS5443-2016 The Dynamic Duo: ODS Layout and the ODS Destination for PowerPoint Jane Eslinger, SAS Institute Inc. ABSTRACT Like a good pitcher and catcher in baseball, ODS layout and the ODS destination for PowerPoint are a winning combination in SAS 9.4. With this dynamic duo, you can go straight from performing data

Evolution of ODS Graphics Early Development of SAS Graphics In the beginning SAS had a less than stellar reputation regarding graphics output. PROC PLOT produced crude raster graphics using a line printer. Then there was SAS/GRAPH and visuals became better. Vector graphics used to produce quality output. Lots of options but too many to learn well (difficult to use “on the fly”).

ODS Graphics Designer Drag & drop, point & click version of graphics -Wide array of plot types -Produces sophisticated graphs ODS Graphics Designer writes the code for you

3 ODS Graphics Designer Eliminates the need to create template styles for graphics Who really mastered PROC TEMPLATE? United States Steel Corporation Preproduction in SAS 9.2 Release 2 (TS2M0) Part of Base SAS in 9.3 (No need for SAS/GRAPH) Drag & Drop and Point & Click version of SG Graphics Let ODS Graphics Designer write the code for you

ODS Graphics is one of the systems used to create analytical graphs in SAS First released with SAS 9.2 as part of SAS/GRAPH From SAS 9.3 onwards, ODS Graphics is part of Base SAS With this system, many SAS analytical procedures create graphics output automatically This system also provides other ways to create custom graphs