Templates for ODS Statistical Graphics
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: ODSGRAPH */
/* TITLE: Templates for ODS Statistical Graphics */
/* PRODUCT: IML */
/* SYSTEM: ALL */
/* KEYS: */
/* PROCS: IML */
/* SUPPORT: SASJEH UPDATE: */
/* DATA: */
/* */
/* MISC: */
/* */
/****************************************************************/
title 'Bar Chart With Options';
proc template;
define statgraph bar;
BeginGraph;
layout overlay;
barchart x=sex/ FILLATTRS=color(color=grey);
endlayout;
EndGraph;
end;
run;
proc iml;
use sashelp.class;
read all var _CHAR_ into matrix [colname = c];
call odsgraph("bar chart", "bar", matrix);
quit;
title "Simple Scatter Plot With Options";
proc template;
define statgraph scatter;
BeginGraph;
layout overlay;
scatterplot x=height y=weight / group=age name="s";
discretelegend "s";
endlayout;
EndGraph;
end;
run;
proc iml;
use sashelp.class;
read all into matrix [colname = c];
call odsgraph("scatter plot","scatter",matrix);
quit;
title 'Scatter Plot Matrix With Options';
proc template;
define statgraph scm;
BeginGraph;
layout gridded;
scatterplotmatrix height weight age /ellipse=(type=mean);
endlayout;
EndGraph;
end;
run;
proc iml;
use sashelp.class;
read all var _num_ into matrix [colname = c];
read all var _char_ into matrixc [colname = cc];
call odsgraph("scatter plot matrix","scm",matrix, matrixc);
quit;
title "Scatter Plot With Ellipse Overlay";
proc template;
define statgraph scatteroverlay;
BeginGraph;
layout overlay;
ellipse x=height y=weight/ alpha=.01 type=predicted
display=(outline fill) OUTLINEATTRS=color(color=black);
scatterplot x=height y=weight;
endlayout;
EndGraph;
end;
run;
proc iml;
use sashelp.class;
read all into matrix [colname = c];
call odsgraph("Scatter And Elipse","scatteroverlay",matrix);
quit;
title 'Surface Plot';
proc template;
define statgraph SurfacePlot;
BeginGraph;
layout overlay3d;
surfaceplotparm x=x y=y z=z / surfacetype=fill;
endlayout;
EndGraph;
end;
run;
proc iml;
XDiv = do( -5, 5, 0.25 );
YDiv = do( -5, 5, 0.25 );
grid = ExpandGrid( XDiv, YDiv );
x = grid[,1];
y = grid[,2];
z = sin( sqrt( x##2 + y##2 ) );
matrix = grid || z;
mattrib matrix colname={"x" "y" "z"};
call odsgraph("surface","SurfacePlot",matrix);
quit;
title;