/
Graphics HRP223 – 2013 Graphics HRP223 – 2013

Graphics HRP223 – 2013 - PowerPoint Presentation

aaron
aaron . @aaron
Follow
350 views
Uploaded On 2018-09-21

Graphics HRP223 – 2013 - PPT Presentation

November 18 2013 Copyright 19992013 Leland Stanford Junior University All rights reserved Warning This presentation is protected by copyright law and international treaties Unauthorized reproduction of this presentation or any portion of it may result in severe civil and crimi ID: 674155

data graphics proc template graphics data template proc ods plots variables grouped plot style continuous run graphic sas sgplot

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Graphics HRP223 – 2013" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Graphics

HRP223 – 2013

November 18, 2013

Copyright ©

1999-2013

Leland Stanford Junior University. All rights reserved.

Warning: This presentation is protected by copyright law and international treaties. Unauthorized reproduction of this presentation, or any portion of it, may result in severe civil and criminal penalties and will be prosecuted to maximum extent possible under the law.Slide2

RobbinsCreating More Effective Graphics by Naomi Robbins is a wonderful book showing the right and wrong ways to visualize scientific data. Read it when you have an afternoon off. It is an ideal read on a transcontinental flight.Slide3

How I do graphicsExploratory stuffUse the quick and dirty graphics built into EGProduction quality graphics

Write SAS or R code to make better looking graphicsEdit in Adobe IllustratorSlide4

Visualization ToolsThis is a excellent book that covers how to visualize stuff using many tools (including R). It has a great introduction to Adobe Illustrator.Slide5

Why Do Data Visualization?Well designed pictures will show you the details and the whole pattern in your data.Numeric descriptions can easily hide important

information.Some patterns are hard to detect in tables.

Whenever data is reported over time or locations, you need art.YOU CAN LEARN A LOT BY JUST LOOKING.-Yogi BerraSlide6

Fisher’s Plot Data Reported in Cleveland

Based on code written by Robert Allison at SAS

Institute

Year 1

Year 2Slide7

Scatter Plot for Correlations

All have r

2

= .67

Anscombe

1973, Graphs in Statistical AnalysisSlide8

Good Statistical GraphicsShow central tendency and variabilityDo not require the reader to think…Include no extra information

Avoids unnecessary inkHighlights they key pointsDirectly plots the conclusion/inference

Uses mnemonic colorsLabels categoriesIncludes the sample sizeSlide9

Bad ThingsFirst, I want to talk about bad graphics that I frequently see.3dExtra Ink

PieDonutsStacked graphicsSlide10

General3D graphicsDon’t, Don’t,

Don’t

While the SAS implementation of 3D graphics is relatively good, don’t use 3D effects, unless you are measuring something in 3D. Even then, don’t.Slide11

Tufte is a God to many.The empiricist in me is very nervous about the amount of pontificating in his books…

I want to have evidence-based advice.His best advice is to put no extra ink on the page.Think about the ink-to-information ratio.

Remove all chart junk.

Note: the irony of the chart junk on this slide….Slide12

Ink-to-Information RatioHow much ink for seven numbers?

Based on

Soukup & Davidson, 2002 Visual Data MiningSlide13

Pie is bad.Work by Cleveland (and experimental psychologists) suggests that:people are bad at judging the relative magnitude of angles

if you twist the rotation of the pie you can cause people to systematically misjudge the size of the angles

a 3rd dimension makes judgment worseIf you get a glossy handout with a 3D pie, assume someone is lying to you.Don’t use them. Slide14

Don’t Explode!This exploded 3D pie (brought to you by Excel) is nearly useless for judging amounts.Slide15

Forbidden Donut….Donut plots have the same problems as pies (if not worse) ….Slide16

ClevelandIf you want to know how to do scientific visualization, you must read William Cleveland’s work.He attempted to quantify what makes a good graphic good.

His early work on graphics is one of the reasons why R/S-plus is taking over the statistical world.Slide17

Stacking is BadCleveland also quantified the fact that people are bad at judging the relative height of stacked data.Slide18

Wow, a cinnamon roll plot!Good luck making rapid judgments using this stacked 3D pie.Slide19

Bar Chart ~ DefaultSlide20

How did I know that?Start using the sgplot documentation:

http://support.sas.com/documentation/cdl/en/grstatproc/64978/HTML/default/viewer.htm#n0yjdd910dh59zn1toodgupaj4v9.htm

… and/or get this: http://library.stanford.edu/bks24_id=45422Slide21

sgplot

documentation:

http://support.sas.com/documentation/cdl/en/grstatproc/64978/HTML/default/viewer.htm#n0yjdd910dh59zn1toodgupaj4v9.htmSlide22

Custom Axis

I prefer to have ticks beyond the largest valueSlide23

yaxis

stuff ;

The popular options are not listed first… Slide24

Ticks on Both Y Axes

Ticks on both axes may help guestimate the countsSlide25

Things in < > are optional argumentsSlide26

Data in Jail

The lines are on top so they look prominent. Can I lighten them?Slide27

OR

Things in < > are optional arguments

A variable name

A number

Optionally add other numbers

Optionally add a

/

and options for the reference line(s)Slide28
Slide29

Line Attributes I wanted to adjust the line attributes so I will use / lineattrs=()

OR

Give a set of line options in ()

A style element with options

I wish I knew how that works…Slide30

Details in parentheses:Slide31

Gray is here…Slide32

Reference Lines

First draw

reference lines

then draw bars on top.Slide33

Reducing InkIn Tufte’s world less ink is good. I could remove the bar color but that is removing necessary ink for this style of plot. I can remove the black edges to the bars.Slide34

Second axis labels are goneSlide35
Slide36

Put White Lines Over the BarsSlide37

Ut

oh…Slide38
Slide39

Awful Design….

I specify a title and it does not show up in the plot.Slide40
Slide41

I want to draw attention to

this.Slide42

Specify you want a different color group for each bar.

Specify the bar and outline colors.Slide43

Notice the blue.Slide44
Slide45

Cleveland made Dot Plots Replace Bar ChartsSlide46

Adding an Offset to the y-axisSlide47

Adding Value LabelsSlide48

Show Frequency CountsSlide49

Label AttributesSlide50
Slide51

You can easily specify that each value is its own color group.Slide52
Slide53

What is a good graphic?Don’t make your audience think unnecessarily!

The point of the graphic should stand out instantly.Plot the quantity (inference) that you want people to notice.

Show the central tendency and the variability.Minimize the amount of ink on the page.Be sure colorblind people can understand it.Use a black and white photocopier and make sure you can distinguish all groups.Slide54

What is wrong with this?

What is the point that the reader should learn from this?

How is the variability represented? What are the error bars? Can you interpret a 1 SD error bars?How many people are included?

Ink to information … How many numbers are depicted?

Never contrast black on blue.Slide55

Another WaySlide56

How did I do that?Slide57
Slide58

Don’t put a legend on the plot, add a pop-up description tooltip for pages on the web and save the graphics template.Slide59

The Graphic TemplatePremade complex plot designs are stored in a graphic template. You can also save the graphic template for any plot you make.Add tmplout

= to the gplot statement.Slide60

The

Template

I gave it a name

Use the new template on the dataset.Slide61

With the title in the graphicSlide62

Another version of the same dataSlide63

Moderately Awful CodeBubble sizes are set by providing a radius… I force the area by setting the smallest and largest bubble size in centimeters.

I want to use this part of the plot for the legend so I name it.Slide64

9.3 How do I set the blue and pink?For grouped data you can specify the details for each plotted element in a style template:Slide65

What is wrong with this?

What is the point of this graphic?

How are the two sexes represented?What data is this?Slide66
Slide67

Easy But Awful BoxplotsSlide68

What is wrong with this?

Lovely white space

What is the point?How are the sexes represented?How many people?Where is the mean?What data is this?Slide69

What is the point of this graphic?

How are the two sexes represented?

A Good BoxplotSlide70

What is the point of this graphic?

A Very Good BoxplotSlide71

Code for a Very Good Boxplot 9.4Slide72
Slide73

Built in GraphicsMany Enterprise Guide analyses have built in diagnostic graphics. Slide74

When you test for the difference in the mean SAS gives you a great plot.Slide75

Avoid ThinkingPut labels on the graphic directly instead of using a key.If you want people to compare the difference between two lines, plot the difference, not the two lines.Slide76

Bivariate Comparisons with LinesPeople are extremely bad at judging the distance between two curves. Never ask people to judge up and down

(vertical) distances between curves.

Based on: Robbins Creating More Effective Graphs, 2005

The distance between the two curves is the same at all points.Slide77

Plot TypesCategorical variablesDescriptiveBar charts

Dot plotsInferentialContinuous variables

HistogramBox plotViolin plotsQuantile and QQ plotsSlide78

Frequency PlotsEG for frequency plotsCustom codeSlide79

I Typically Use HTML

This says the images should show tooltips with extra statistical details when you hover the mouse over parts of the graphic. (I can’t image these.)

This is the appearance template. For optimal results use:

Analysis: color

Default :

overdistinguishes

symbols for color or B&W

Journal or journal2, etc: black and white

Statistical or statistical2, etc: color

Include

image_dpi

= 300 to set the resolution to be higher than the default 100 dots per inch. Try 300 for final images pasting into MS Office.Slide80

ods graphics on;This turns on the ODS statistical graphics.Behind the scenes this combines your data with a pre-specified description of what to plot and the aesthetics of the appearance.

Your data

Graph

template

Style

template

What

Where?

Colors

FontsSlide81

Useful ods graphics optionsods graphics on /

ods graphics / reset;ods graphics off;

Width = 8inHeight = 11inImagefmt = jpgimagename = thingyimagefmt = staticmap ;

Make a series of graphics called thingy1, thingy2, etc.

If you set only width or height, it will use a 4:3 aspect ratio.

Reset the graphic counter back to 1

Use pop-up tooltips with details.

If you want to disable ods graphics for a procedureSlide82
Slide83

ODS Graphics Editor with EGIf you want to do extensive tweaking to a graphic, you can use the WYSIWYG ODS Graphics editor. Unfortunately it only works with ODS graphics procedures and you need to rerun the code

in SAS to invoke it.Slide84

Move code from EG to SASUse the query builder to put your data in a permanent SAS library (

not the work library).Right click on the graphic node which is run on data in a permanent library and choose Open… Open Last Submitted Code.

Copy the code beginning with the SQL that makes the data.Start SAS and paste the code into the program editor.Slide85

Move all your code to SASBecause the ODS graphics editor is not in EG (yet), you can export the entire set of code for the project and then rerun it in SAS.Slide86

ODS Graphics Editor with EG(2)After exporting all your EG project, open the code in SAS and add these lines at the top of the program:

ods rtf file = "c:\blah\somefile.rtf";ods listing sge

= on;Then open the graphic of interest.Slide87
Slide88

WYSIWYG EditingRight click and/or double click to set properties for objects in the plot.

The tool is optimized for some of the ODS style templates but you can use custom colors.Slide89

Right click on things to set properties. Colors, text details, fontsPoint and click annotationSymbols, arrows, text, circlesSlide90

WYSIWYG EditingWhile the Statistical graphics editor is a much needed improvement, it is incomplete. You can only use a few, style templates (for setting default colors and such) and you can not use custom style templates. This means that you can not do critical tasks like manually set the color for different values in scatter plots.Slide91

Bar ChartsThe ink-to-information ratio is lousy.A one dimensional quantity is being “expanded” into two dimensions. Doubling of the amount corresponds to how much of an increase in area?Slide92

SAS Bar ChartsSAS makes the reader do extra work by rotating the axis labels in ActiveX images. They pointlessly include variable labels by default.Slide93

How to do it?

Notice you can Edit the data and apply filters.

You can right click on variables and apply user-defined formats off the Properties dialog.Slide94

First create the format.

In the Data windowpane of the Bar Chart GUI, right click on the variable and change the format to the User Defined format you had created.Slide95

The GUI is SolidMy only complaints are that the rotate grouping values text does not work (position in this example) and the summary statistics do not show up when you request ActiveX images.Slide96

.PNG formatActiveX image formatSlide97

Saving the Graphic for PublicationThe easiest way to get publication quality graphics is to set the output type to be RTF.Slide98

Default Output and GraphicsThe default graphic format in EG is ActiveX. These images can be edited (even on the web) but they only display with Internet Explorer. I have set my graphics to display as ActiveX images. Tweak this with Tools> Options… > Graph.Slide99
Slide100

Types of ImagesThe default formats

of the images are determined by the ODS destinations you are using:LISTING:

pgn visible in the Windows Image Fax ViewerHTML: png, gif, jpg contained in web pages and visible in Internet Explorer, Firefox or OperaLATEX: PostScrpt, epsi, gif, jpeg, pgn

are visible in

GhostView

PCL or PS: contained in Postscript file are visible in

GhostView

PDF: contained in

pdf

, which is visible with Adobe Reader

RTF: visible in MS Word

RTF graphics are done at 300 dpi by defaultSlide101

You can browse the ODS appearance templates from the

Style

Manager on the Tools menu.Slide102

ODS SGraphicsCompared to the competition, for the last 10 years SAS graphics have been between poor and pathetic.Graphics procedures rendered with okay quality, at best .

No “what you see is what you get” editing.Many plots were nearly impossible to render.

Custom graphics required extensive programming.SAS 9.x has attempted to solve this problem.Slide103

Old vs. New ProceduresThe old (commonly used) graphics procedures were gchart, gplot

.Now most analysis procedures have built in high quality graphics that can be invoked with an ODS graphics on statement.

Early on in the class I told you to tweak the EG options to include “ODS graphics on” with every run.There are also new “easy to use” statistical graphics (sg) procedures.Slide104

New Graphics Statistical Graphics Procs

proc

sgPlotgeneral plotting procedure that replaces gplotproc sgScatterlots of tools for scatterplots and scatter matricesproc sgPanel

quick and easy trellis/lattice/matrix/panel of plots

Proc

sgRender

used with proc template to make totally custom plots

It replaces proc

greplaySlide105

Plot TypesCategorical variablesBar chartsDot plots

Continuous variablesHistogramBox plot

Violin plotsQuantile and QQ plotsSlide106

Dot charts

Categorical variablesSlide107

Grouped Categorical VariablesTo graph categorical data in SAS you need to get Michael Friendly’s Visualizing Categorical Data. Unfortunately, his macros are copyrighted with the book… So I will show you the R versions.

Fourfold plotsMosaic plotsAssociation plots

Grouped categorical variablesSlide108

If you want to use RDownload R for Mac or PC cran.cnr.berkeley.edu/bin/

macosx/

cran.cnr.berkeley.edu/bin/windows/baseSlide109

How to learn RI usually teach R classes in the summer.www.stanford.edu/~balise

/ has links to my slide decks for R classes.Slide110

Plots for inferenceCategorical plotsConfidence limits on odds ratiosFour-fold plots

Expectancy plotsMosaic plotsSlide111

Fourfold PlotsThey draw 4 slices of pie with the area corresponding to the number of people in each cell of a 2x2 table and they have confidence bands such that if the confidence bounds overlap on adjacent pie pieces, they are not statistically significantly different.

Grouped categorical variables

45% male vs

.

30% female

admission Slide112

More males were admitted than females.There is clear evidence of sexist policies in admissions!

Grouped categorical variablesSlide113

Department A admitted more females than males and every other department had no bias!The joy of Simpsons paradox.

Grouped categorical variablesSlide114

Mosaic PlotsSo you have an contingency table and you want to know if there is as an association. You do a chi-square test and it says there are associations between the rows and columns. What next?

Grouped categorical variablesSlide115

Some basic voodoo in R shows which combinations are over (in blue) or under represented (in red).

Grouped categorical variablesSlide116

I prefer the simpler association plots.

Grouped categorical variablesSlide117

Continuous OutcomesThe Distribution Analysis menu option can do basic plots.

Continuous variablesSlide118

The resolution of the histogram is okay but the others are unacceptable.Slide119

Use sgplot for high resolution plots.

Continuous variablesSlide120

As you add more requests to the plot, it resizes and shifts things to make room. It draws them in the order you request them. It reads the requests from the first listed to the bottom. Change the order if you want to have an item appear layered on top of, or behind, another thing.

Some colors are not set yet in the enhanced editor. Use the menu Tools>Options>Enhanced Editor… then click User Defined Keywords to add the coloring.Slide121

I want the title!Slide122

How is that made?proc

format library = work; value

$smoked

"Non-smoker"

=

"None "

missing =

"Missing"

other =

"Not none"

;

run

;

data

fram

;

set

sashelp.heart

;

smokin

= put(

smoking_Status

,

$smoked.

);

run

;Slide123

How is that made?title

"5209 Cholesterol Measures from Framingham Heart Study"

;proc sgplot

data

=

fram

tmplout

=

"c:\blah\

plate.sas

"

;

histogram

cholesterol;

density

cholesterol /

type

=

kernel

;

density

cholesterol /

type

=

normal

;

keylegend

/

location

=

inside

position

=

topright

across

=

1

;

run

;

Make a new graphics templateSlide124

proc template

;define

statgraph sgplotFram;begingraph

/;

EntryTitle

"5209 Cholesterol Measures from Framingham Heart Study"

/;

layout

overlay

;

Histogram

'

Cholesterol'n

/

primary

=true

binaxis

=false

LegendLabel

=

"Cholesterol"

;

DensityPlot

'

Cholesterol'n

/

Lineattrs

=

GraphFit

kernel

()

LegendLabel

=

"Kernel"

NAME

=

"DENSITY"

;

DensityPlot

'

Cholesterol'n

/

Lineattrs

=GraphFit2

normal

()

LegendLabel

=

"Normal"

NAME

=

"DENSITY1"

;

DiscreteLegend

"DENSITY"

"DENSITY1"

/

Location

=Inside

across

=

1

halign

=right

valign

=top;

endlayout

;

endgraph

;

end

;

run

;

proc

sgrender

data

=

work.fram

template

=

template

=

sgplotFram

;

run

;

This was saved in

plate.sas

.

Render a graphic with the template and dataset specified.

Note I changed the name of this template.Slide125

How to set the color for a histogramSlide126

proc sgplot

data = fram; histogram

weight /

fillattrs

= (

color

= coral);

run

;Slide127

You can also tweak the style templateSlide128

Tweaking the Style Templateproc

template; define style

myStyle

;

parent =

styles.Statistical

;

style

GraphDataDefault

/

color

=coral

;

end

;

run

;

ods

html

style

=

myStyle

;

proc

sgplot

data

=

fram

;

histogram

weight ;

run

;

ods

html

close

;Slide129

vbar Versionproc

sgplot

data = fram;

vbar

weight /

group

= sex;

run

;Slide130

proc sgplot

data

= fram; vbar weight /

group

= sex;

xaxis

fitpolicy

=

thin

;

run

;Slide131

proc

template;

define style

myStyle

;

parent

=

styles.Statistical

;

style

graphdata1 from graphdata1 /

contrastColor

=pink

color

= pink;

style

graphdata2 from graphdata1 /

contrastColor

=blue

color

= blue;

end

;

run

;

ods

html

style

=

myStyle

;

proc

sgplot

data

=

fram

;

vbar

weight /

group

= sex;

xaxis

fitpolicy

=

thin

;

run

;

ods

html

close

;Slide132

Customizing graphicsYou can tweak the graphics that ship with SAS by modifying their graph template or you can create truly custom graphics by making your own statistical graph template.

Your data

Graph

template

Style

templateSlide133

If you do not want to explain what Kernel density estimation is… remove the lines.Slide134

Finding the templateAdd before the procedure that draws the graphic add ods trace on; and include

ods trace off; afterwards. This prints the names of all the templates used by the procedure in the log.

product.procedure.Graphis.TemplateNameSlide135

Looking at a TemplateYou can ask proc template to display the template with the source statement:

proc

template; source stat.ttest.graphics.summary2;

run

;

Remember to type this before you start editing:

ods

path

(

prepend

)

work.template

(

update

);Slide136

Don’t Panic

This is a complete template except for the

proc template

statement here and a

run

statement at the bottom.

Copy this into an editor window and add proc template.Slide137

After adding proc template and commenting out the Kernel statements rerun the code.Slide138

Oops. Unknown key words…You can fix the color coding on the template code easily.Slide139

Fixed (permanently)All your subsequent plots will have no density line.Slide140

Continuous variablesSlide141

ViolinA violin plot mirrors the shape of the histogram (density). They can be done in R.

Continuous variablesSlide142

Grouped Continuous VariablesYou can use the Distribution Analysis to get basic grouped plots.For better looking plots you need to write sgplot and/or sgpanel code.

Grouped continuous variablesSlide143

Request distinct graphics by subgroups.

Grouped continuous variablesSlide144

Grouped continuous variablesSlide145

Actually this took a bit of voodoo.

Grouped continuous variablesSlide146

1

st

2nd

Grouped continuous variablesSlide147

Double click here.

Put details on the histogram tweaks here.

I use/tweak

nrow

ncol

and endpoints often.

endpoints = 2 to 10 by 0.5

midpoints = 5.6 5.8 6.0 6.2 6.4

Grouped continuous variablesSlide148

Grouped continuous variablesSlide149

Grouped continuous variablesSlide150

I want to add in a reference line showing what is normal and put the categories in order.Slide151
Slide152

Side by Side Violin Plots

Grouped continuous variablesSlide153

Paired Continuous VariablesPeople typically show paired data with scatterplots.EG generate them:

Grouped continuous variablesSlide154

Scatter Plot

Grouped continuous variablesSlide155

Jittered PlotSlide156

Jitter vs. SunflowersIn R you can also do sunflower plots.

Grouped continuous variablesSlide157

Ordinary Least Squares RegressionPeople typically plot a regression line to show a relationship between two continuous variables.

Grouped continuous variablesSlide158

Regression lineYou can easily add a regression line to the scatter plot.Slide159

proc

sgplot data =

fram

;

scatter

x

= height

y

= weight;

run

;

proc

sgplot

data

=

fram

;

reg

x

= height

y

= weight;

run

;Slide160

ods listing

sge = on style = statistical;

proc

sgplot

data

=

fram

;

reg

x

= height

y

= weight /

markerattrs

= (

color

= green)

lineattrs

= graphdata1 (

color

= lime);

run

;Slide161

ods

listing style

= statistical;

proc

sgplot

data

=

fram

;

reg

x

= height

y

= weight /

group

= sex ;

run

;Slide162

proc template

;

define style sexE;

parent

=

styles.Statistical

;

style

graphdata1 /

contrastColor

=pink

markersymbol

=

"star"

;

style

graphdata2 /

contrastColor

=blue

markersymbol

=

"plus"

;

end

;

run

;

ods

html

body

=

"C:\blah\stuff.html"

gpath

=

"c:\blah"

style

=

sexE

;

proc

sgplot

data

=

fram

;

scatter

x

= height

y

= weight /

group

= sex ;

reg

x

= height

y

= weight /

group

= sex ;

run

;

ods

html

close

;Slide163
Slide164

BisquareFigure out what is an odd value and then put a weight on it to devalue it. There are many robust regression algorithms around. R and S-Plus software have them well implemented.

Grouped continuous variablesSlide165

Loess and SplinesLoess is a technique essentially creates a rolling window and gets a weighted average across the values visible inside the window

.Splines are curved lines that allow different amounts of stiffness to the curves.

Grouped continuous variablesSlide166

Smooth = 25

Smooth = 50

Smooth = 99Slide167

Proc phreg

has a lot of new features but nothing major in the graphics. With

phreg

, if you specify

ods graphics on

you do not automatically get any plots. Here I request survival and cumulative hazard plots including the global confidence limits option (

cl

).

Once again the option names are not consistent with the table names.Slide168

Proc

lifetest

can show the number at risk but the implementation is weak. It labels the groups with numbers even if the strata are character strings. You have to manually edit them and this affords ample opportunity for mistakes.I don’t see a way to change the censoring symbol in the legend.

This shows the number of people at risk after 20, 40 etc days.Slide169

Too Many GraphicsIf the ods graphics on

statement gives you too many graphics, you can specify which graphics you want by including code designed for the procedure. Typically it looks like this:

plot(only) = (table names). This design is poorly implemented because you need to know where to put the plot statement and what the table names are. Does it go on the proc line (like phreg), the tables line (like proc freq), or some other line? Also the table names specified with a plot statement do not always match the ODS table names.Slide170

Usually you can use an ODS exclude statement or an ODS select statement to pick the correct things to print. Using the plots(only) = syntax is more efficient.Slide171

Splitting a GridSome procedures produce a grid of plots. You can get access to the individual plots by specifying plots(unpack). Then you can use plots(only)=

tableName to get just the right parts.ODS select or exclude statements will not work. Slide172

plots(

GlobalOptionsGoHere

). The global options apply to all graphics in this procedure.Slide173

Beyond the Basic Univariate plotsThere are 4 SG procedures that allow you to build up complex univariate plots and do multivariate (trellis/lattice) plots.Slide174

Statistical Graphics Procs

proc

sgPlotgeneral plotting procedure that replaces gplotProc sgRenderused with proc template to make totally custom plotsIt replaces proc greplayproc sgScatter

lots of tools for

scatterplots

and scatter matrices

proc

sgPanel

quick and easy trellis/lattice/matrix/panel of plotsSlide175

GridsYou can produce lattices full of graphics with proc gpanel.Slide176
Slide177

Spaghetti Plots

Data from Singer and Willett: www.ats.ucla.edu/stat/examples/alda.htmSlide178

SGPlot vs TemplateYou can replicate everything done with proc sgplot using the template language but don’t reinvent the wheel if you don’t need to.

You will want to use proc template to build custom graphics that use many panels.Proc sgplot uses statements that start like

reg but template uses names like regressionplot. Similar but not identical names… boo.Slide179
Slide180
Slide181

layout gridded = ticks do not have to align

layout lattice = ticks must alignSlide182
Slide183