Top Banner
Ods Graphics Anders Nilsson Onsdag 23 maj, 2013 Anders Nilsson
36

Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor.....

Mar 22, 2018

Download

Documents

trannhi
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics

Anders Nilsson

Onsdag 23 maj, 2013

Anders Nilsson

Page 2: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Nytt i 9.2, del av SAS/GRAPH

Flyttat till Base i 9.3

Vad är Ods Graphics?

ODS Graphics(Template-based)

SAS/GRAPH(Device-based)

Två ramverk för att göra diagram

Page 3: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

”Template-based graphics”

Ods Graphics och GTL

Graph Template

SAS Data Set

Style Template +

+

proc template; define style Styles.Default;

class GraphFonts"Fonts used in graph styles" / 'GraphDataFont' = ("<sans-serif>, <MTsans-serif>",7pt) 'GraphUnicodeFont' = ("<MTsans-serif-unicode>",9pt) 'GraphValueFont' = ("<sans-serif>, <MTsans-serif>",9pt) 'GraphLabel2Font' = ("<sans-serif>, <MTsans-serif>",10pt) 'GraphLabelFont' = ("<sans-serif>, <MTsans-serif>",10pt,bold) 'GraphFootnoteFont' = ("<sans-serif>, <MTsans-serif>",10pt) 'GraphTitleFont' = ("<sans-serif>, <MTsans-serif>",11pt,bold);

Page 4: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - Innehåll

Enkelt

Medel

Svårt

Väldigt enkeltFönstermiljöerODS Graphics EditorODS Graphics Designer

Diagram via statistik-procTex. Freq, reg, ttest,…

SG-procTex. SGplot, SGscatter,

SGpanel,...

GTL+SGrenderProc template

Page 5: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics Editor

ods listing sge=on;

Page 6: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics Designer

Page 7: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics Designer

proc template;

define style styles.MinNyaStil;

parent=styles.LISTING;

class GraphData1 /

lineStyle = 1

markerSymbol = "circle"

color = CX00FF00

contrastColor = CX2A25D9;

class GraphData2 /

lineStyle = 4

markerSymbol = "plus"

color = CXFFFF00

contrastColor = CX00FFFF;

class GraphData3 /

lineStyle = 8

markerSymbol = "X"

color = CX2A25D9

contrastColor = CX01665E;

end;

run;

Page 8: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - färdiga graph-templates

ods graphics on;

proc reg data=sashelp.class;

model weight=height;

run;quit;

ods graphics off;

Page 9: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

ods graphics on;

proc reg data=sashelp.class plots(only)=fit;

model weight=height;

run;quit;

ods graphics off;

Ods Graphics - färdiga graph-templates

Page 10: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

ods graphics on;

proc freq data=sashelp.class ;

table age / plots=freqplot;

run;

ods graphics off;

Ods Graphics - färdiga graph-templates

Page 11: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics hjälp

Page 12: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Base SAS SAS/STAT SAS/QC SAS/ETS

CORR

FREQ

UNIVARIATE

ANOVA

BOXPLOT

CALIS

CLUSTER

CORRESP

FACTOR

FMM

GAM

GENMOD

GLIMMIX

GLM

GLMPOWER

GLMSELECT

KDE

KRIGE2D

LIFEREG

LIFETEST

LOESS

LOGISTIC

MCMC

MDS

MI

MIXED

MULTTEST

NLIN

NPAR1WAY

ORTHOREG

PHREG

PLM

PLS

POWER

PRINCOMP

PRINQUAL

PROBIT

QUANTREG

REG

ROBUSTREG

RSREG

SEQDESIGN

SEQTEST

SIM2D

SURVEYFREQ

SURVEYLOGISTIC

SURVEYPHREG

SURVEYREG

TPSPLINE

TRANSREG

TTEST

VARCLUS

VARIOGRAM

ANOM

CAPABILITY

CUSUM

MACONTROL

MVPCHART

MVPMODEL

PARETO

RELIABILITY

SHEWHART

HPF

HPFENGINE

SAS Risk

Dimensions

ARIMA

AUTOREG

COPULA

ENTROPY

ESM

EXPAND

MODEL

PANEL

SEVERITY

SIMILARITY

SYSLIN

TIMEID

TIMESERIES

UCM

VARMAX

X12

OTHER

Ods Graphics - färdiga graph-templates

Page 13: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics – SGproc:ar

SGplot

SGscatter

SGpanel

SGrender

SGdesign

Page 15: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - SGplot

BAND

BUBBLE

DENSITY

DOT

ELLIPSE

HBAR

HBARPARM

HBOX

HIGHLOW

HISTOGRAM

HLINE

VBAR

VBARPARM

VBOX

VECTOR

VLINE

WATERFALL

XAXIS

X2AXIS

YAXIS

Y2AXIS

INSET

KEYLEGEND

LINEPARM

LOESS

NEEDLE

PBSPLINE

REFLINE

REG

SCATTER

SERIES

STEP

Page 16: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - SGplot

proc sgplot data=t1;

vbar year / response=total stat=sum;

run;

Page 17: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - SGplotproc sgplot data=t1;

vbar year / response=total stat=sum

group=order_type

dataskin=pressed;

run;

9.3

Page 18: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - SGplotproc sgplot data=exdata.linje;

series x=date y=close;

run;

Page 19: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - SGplotproc sgplot data=exdata.linje;

band x=date upper=high lower=low / fillattrs=(color=CXC0FF81);

series x=date y=close;

series x=date y=high / lineattrs=(color=red pattern=shortdash);

series x=date y=low / lineattrs=(color=red pattern=shortdash);

refline 95 / lineattrs=(color=red);

run;

Page 20: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - SGplotproc sgplot data=sashelp.class;

vbox height / category=sex

capshape=bracket

connect=mean

connectattrs=(color=red);

run;

9.3

Page 21: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics –Annotate (9.3)

Ovanpå ditt diagram kan du lägga till text, linjer, pilar, ovaler, rektanglar, polygoner, bilder.

4 typer av variabler:• Vad ska ritas? • Var ska detta ritas?• Koordinatsystem• Vilka attribut? Färg, linjetyp, osv.

Diagram-data

Annotate-data

+

Page 22: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics –Annotate (9.3)

proc sgplot data=orion.profit sganno=AnnotateTabell;

vbar country/ response=sales stat=mean;

run;

Page 23: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics –Attribute map (9.3)

title 'Summan av längder';

proc sgplot data=sashelp.class dattrmap=AttributeTabell;

vbar age / response=height group=sex

groupdisplay=cluster attrid=gdr;

run;

Page 24: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

GTL = Graph Template Language

• Generera GTL-kod genom att peka och klicka

• Färdig GTL-kod används (finns i SasHelp)

• GTL-kod genereras automatiskt från SG-koden

• Skriv egen GTL-kod

Page 25: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

Proc SGplot

+Data+Style

Diagram

GTL

Page 26: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

proc sgplot data=sashelp.class tmplout="MittGTLpgm.sas";

reg x=height y=weight / cli clm;

run;

Page 27: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

proc template;

define statgraph sgplot;

begingraph /;

layout overlay;

ModelBand "G76FA8QG" / display=(outline)

OutLineAttrs=GraphPredictionLimits Name="MODELBAND"

LegendLabel="95% Prediction Limits";

ModelBand "G76FA8QH" / Name="MODELBAND1" LegendLabel="95%

Confidence Limits";

ScatterPlot X=Height Y=Weight / primary=true;

RegressionPlot X=Height Y=Weight / NAME="REG"

LegendLabel="Regression" clm="G76FA8QH" cli="G76FA8QG";

DiscreteLegend "MODELBAND" "MODELBAND1" "REG";

endlayout;

endgraph;

end;

run;

Page 28: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

proc template;

define statgraph sgplot;

begingraph /;

layout overlay;

ModelBand "G76FA8QG" / display=(outline)

OutLineAttrs=GraphPredictionLimits Name="MODELBAND"

LegendLabel="95% Prediction Limits";

ModelBand "G76FA8QH" / Name="MODELBAND1" LegendLabel="95%

Confidence Limits";

ScatterPlot X=Height Y=Weight / primary=true;

RegressionPlot X=Height Y=Weight / NAME="REG"

LegendLabel="Regression" clm="G76FA8QH" cli="G76FA8QG";

DiscreteLegend "MODELBAND" "MODELBAND1" "REG";

endlayout;

endgraph;

end;

run;

Page 29: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

proc template;

define statgraph MinGTL;

dynamic minvariabel;

begingraph;

entrytitle 'GTL-histogram';

layout overlay;

histogram minvariabel ;

referenceline x=eval(mean(minvariabel)+2*std(minvariabel)) /

lineattrs=(pattern=dash);

referenceline x=eval(mean(minvariabel)-2*std(minvariabel)) /

lineattrs=(pattern=dash);

referenceline x=eval(mean(minvariabel)) /

lineattrs=(color=red thickness=3);

endlayout;

endgraph;

end;

run;

Page 30: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

proc template;

define statgraph MinGTL;

dynamic minvariabel;

begingraph;

entrytitle 'GTL-histogram';

layout overlay;

histogram minvariabel ;

referenceline x=eval(mean(minvariabel)+2*std(minvariabel)) /

lineattrs=(pattern=dash);

referenceline x=eval(mean(minvariabel)-2*std(minvariabel)) /

lineattrs=(pattern=dash);

referenceline x=eval(mean(minvariabel)) /

lineattrs=(color=red thickness=3);

endlayout;

endgraph;

end;

run;

Page 31: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

proc sgrender data=sashelp.heart template=MinGTL;

dynamic minvariabel='cholesterol';

run;

Page 32: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

proc sgrender data=sashelp.cars template=MinGTL;

dynamic minvariabel='weight';

run;

Page 33: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

proc fcmp outlib=work.minafknr.grupp;

function bmi(langd,vikt);

return(vikt/langd**2);

endsub;

function klass(bmi) $ 10;

if bmi<18.5 then return('Undervikt');

if bmi<25 then return('Normalvikt');

if bmi<30 then return('Övervikt');

return('Fetma');

endsub;

run;

options cmplib=minafknr;

Page 34: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

proc template;

define statgraph MinGTL;

dynamic height weight;

begingraph;

entrytitle 'GTL-bubbel';

layout overlay;

bubbleplot x=height y=weight

size=eval(bmi(height/100,weight)) /

group=eval(klass(bmi(height/100,weight)))

name='bubbel'

dataskin=matte;

discretelegend 'bubbel';

endlayout;

endgraph;

end;

run;

Page 35: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Ods Graphics - GTL

proc sgrender data=htwt template=MinGTL;

dynamic height="langd" weight="vikt";

run;

Page 36: Ods Graphics - SAS - Analytics, Business Intelligence and ... · PDF fileOds Graphics - Innehåll Enkelt Medel Svårt Väldigt enkelt Fönstermiljöer ODS Graphics Editor ODS Graphics

Frågor?