Ods Graphics

Download Report

Transcript Ods Graphics

Ods Graphics
Anders Nilsson
Onsdag 23 maj, 2013
Anders Nilsson
Vad är Ods Graphics?
Nytt i 9.2, del av SAS/GRAPH
Flyttat till Base i 9.3
Två ramverk för att göra diagram
SAS/GRAPH
(Device-based)
ODS Graphics
(Template-based)
Ods Graphics och GTL
”Template-based graphics”
Graph Template
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);
SAS Data Set
+
Ods Graphics - Innehåll
Fönstermiljöer
ODS Graphics Editor
ODS Graphics Designer
Väldigt enkelt
Diagram via statistik-proc
Tex. Freq, reg, ttest,…
Enkelt
SG-proc
Tex. SGplot, SGscatter,
SGpanel,...
Medel
GTL+SGrender
Proc template
Svårt
Ods Graphics Editor
ods listing sge=on;
Ods Graphics Designer
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;
Ods Graphics - färdiga graph-templates
ods graphics on;
proc reg data=sashelp.class;
model weight=height;
run;quit;
ods graphics off;
Ods Graphics - färdiga graph-templates
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
ods graphics on;
proc freq data=sashelp.class ;
table age / plots=freqplot;
run;
ods graphics off;
Ods Graphics hjälp
Ods Graphics - färdiga graph-templates
Base SAS
CORR
FREQ
UNIVARIATE
SAS/STAT
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
SAS/QC
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
OTHER
HPF
HPFENGINE
SAS Risk
Dimensions
SAS/ETS
ARIMA
AUTOREG
COPULA
ENTROPY
ESM
EXPAND
MODEL
PANEL
SEVERITY
SIMILARITY
SYSLIN
TIMEID
TIMESERIES
UCM
VARMAX
X12
Ods Graphics – SGproc:ar
SGplot
SGscatter
SGpanel
SGrender
SGdesign
Ods Graphics - SGplot
Ods Graphics - SGplot
BAND
BUBBLE
DENSITY
DOT
ELLIPSE
HBAR
HBARPARM
HBOX
HIGHLOW
HISTOGRAM
HLINE
INSET
KEYLEGEND
LINEPARM
LOESS
NEEDLE
PBSPLINE
REFLINE
REG
SCATTER
SERIES
STEP
VBAR
VBARPARM
VBOX
VECTOR
VLINE
WATERFALL
XAXIS
X2AXIS
YAXIS
Y2AXIS
Ods Graphics - SGplot
proc sgplot data=t1;
vbar year /
response=total stat=sum;
run;
Ods Graphics - SGplot
proc sgplot data=t1;
vbar year /
response=total stat=sum
group=order_type
dataskin=pressed;
9.3
run;
Ods Graphics - SGplot
proc sgplot data=exdata.linje;
series x=date y=close;
run;
Ods Graphics - SGplot
proc 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;
Ods Graphics - SGplot
proc sgplot data=sashelp.class;
vbox height / category=sex
capshape=bracket
connect=mean
connectattrs=(color=red);
run;
9.3
Ods Graphics – Annotate (9.3)
Ovanpå ditt diagram kan du lägga
till text, linjer, pilar, ovaler,
rektanglar, polygoner, bilder.
Diagramdata
Annotatedata
+
4 typer av variabler:
• Vad ska ritas?
• Var ska detta ritas?
• Koordinatsystem
• Vilka attribut? Färg, linjetyp, osv.
Ods Graphics – Annotate (9.3)
proc sgplot data=orion.profit sganno=AnnotateTabell;
vbar country/ response=sales stat=mean;
run;
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;
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
Ods Graphics - GTL
Proc SGplot
GTL
+
Data
+
Style
Diagram
Ods Graphics - GTL
proc sgplot data=sashelp.class tmplout="MittGTLpgm.sas";
reg x=height y=weight / cli clm;
run;
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;
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;
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;
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;
Ods Graphics - GTL
proc sgrender data=sashelp.heart template=MinGTL;
dynamic minvariabel='cholesterol';
run;
Ods Graphics - GTL
proc sgrender data=sashelp.cars template=MinGTL;
dynamic minvariabel='weight';
run;
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;
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;
Ods Graphics - GTL
proc sgrender data=htwt template=MinGTL;
dynamic height="langd" weight="vikt";
run;
Frågor?