%let gpath='.';
ods html close;
%let dpi=200;
ods listing gpath=&gpath image_dpi=&dpi;
/*--Simple Scatter Plot--*/
ods listing image_dpi=200;
ods graphics / reset width=5in height=3in imagename='Scatter';
title 'Weight by Height';
proc sgplot data=sashelp.class;
scatter x=height y=weight;
run;
title;
/*--Scatter Plot with Groups--*/
ods listing image_dpi=200;
ods graphics / reset width=5in height=3in imagename='ScatterGroup';
title 'Weight by Height by Gender';
proc sgplot data=sashelp.class;
scatter x=height y=weight / group=sex;
run;
title;
/*--Scatter Plot with Groups and style attrs--*/
ods listing image_dpi=200;
ods graphics / reset width=5in height=3in imagename='ScatterGroupMarkers';
title 'Weight by Height by Gender';
proc sgplot data=sashelp.class;
styleattrs datasymbols=(circlefilled trianglefilled)
datacontrastcolors=(olive maroon);
scatter x=height y=weight / group=sex filledoutlinedmarkers
markerattrs=(size=12) markerfillattrs=(color=white)
markeroutlineattrs=(thickness=2);
keylegend / location=inside position=bottomright;
run;
title;
/*--Define Image files for Marker Icons--*/
%let fileM=C:\Male.png;
%let fileF=C:\Female.png;
/*--Create data set--*/
data class;
length label $10;
set sashelp.class;
if weight < 60 then label=name;
if weight > 140 then label=name;
run;
/*--Scatter Plot with Groups and Group Image Icons--*/
ods listing image_dpi=200;
ods graphics / reset noborder width=5in height=3in imagename='ScatterGroupImageMarkers';
title 'Weight by Height by Gender';
proc sgplot data=class noborder noautolegend;
symbolimage name=male image="&fileM";
symbolimage name=female image="&fileF";
styleattrs datasymbols=(male female);
scatter x=height y=weight / group=sex markerattrs=(size=20)
datalabel=label datalabelpos=bottom;
xaxis offsetmin=0.05 offsetmax=0.05 display=(noline noticks) grid;
yaxis offsetmin=0.1 offsetmax=0.05 display=(noline noticks) grid;
run;
title;