%let gpath='C:\';
%let dpi=200;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;
/*--Reduce plot data to Sedans only--*/
data sedans;
set sashelp.cars(where=(type='Sedan'));
run;
/*--Scatter Plot with Data Labels--*/
proc template;
define statgraph ClassScatterLabel;
begingraph;
entrytitle 'Weight by Height';
layout overlay;
scatterplot x=height y=weight / datalabel=name group=sex;
endlayout;
endgraph;
end;
run;
/*--Scatter Plot with data labels--*/
ods graphics / reset width=2.5in height=1.75in imagename='ClassScatterLabel';
proc sgrender data=sashelp.class template=ClassScatterLabel;
run;
/*--Reduce data labels--*/
data sedanLabels;
length label $20 Segment $10;
set sedans;
keep label horsepower msrp segment;
if msrp > 70000 then do;
label=model;
Segment='Luxury';
end;
else Segment='General';
run;
/*proc print;run;*/
/*--Scatter Plot with Reduced Data Labels--*/
proc template;
define statgraph CarsScatterLabel;
begingraph;
entrytitle 'Horsepower by MSRP';
layout overlay;
scatterplot x=msrp y=horsepower / datalabel=label dataskin=gloss group=label
datatransparency=0.3 markerattrs=(symbol=circlefilled size=15)
datalabelattrs=(weight=bold);
endlayout;
endgraph;
end;
run;
/*--Scatter Plot with reduced data labels--*/
ods graphics / reset width=2.5in height=1.75in imagename='CarsScatterLabel';
proc sgrender data=sedanLabels template=CarsScatterLabel;
run;
/*--Sort Table--*/
proc sort data=sashelp.class out=class;
by height;
run;
/*--Cars Table--*/
data classTable;
set class(where=(sex='F'));
Ht_loc=70;
if mod(_n_, 2) then RefName=name;
run;
/*proc print;run;*/
/*--Scatter Plot MarkerCharacter--*/
proc template;
define statgraph ClassMarkerCharacter;
begingraph;
entrytitle 'Weight by Height for All Students';
layout overlay;
scatterplot x=height y=weight / markercharacter=name
markercharacterattrs=(weight=bold) group=sex;
endlayout;
endgraph;
end;
run;
/*--Scatter Plot with MarkerCharacter--*/
ods graphics / reset width=2.5in height=1.75in imagename='ClassMarkerCharacter';
proc sgrender data=sashelp.class template=ClassMarkerCharacter;
run;
/*--Scatter Plot MarkerCharacter Table--*/
proc template;
define statgraph ClassTable;
begingraph;
entrytitle 'Height of All Girls in Class';
layout overlay;
scatterplot x=height y=name / markerattrs= graphdata2(symbol=circlefilled);
scatterplot x=ht_Loc y=name / markercharacter=height markercharacterattrs=(weight=bold);
endlayout;
endgraph;
end;
run;
/*--Scatter Plot with MarkerCharacter--*/
ods graphics / reset width=2.5in height=1.75in imagename='ClassTable';
proc sgrender data=classTable template=ClassTable;
format height weight 4.1;
run;
/*--Axis Options--*/
proc template;
define statgraph ClassTableAxis;
begingraph;
entrytitle 'Height of All Girls in Class';
layout overlay / xaxisopts=(griddisplay=on)
yaxisopts=(display=(tickvalues) offsetmin=0.05 offsetmax=0.05);
referenceline y=refname / lineattrs=(thickness=15) datatransparency=0.8;
scatterplot x=height y=name / markerattrs= graphdata2(symbol=circlefilled);
scatterplot x=ht_Loc y=name / markercharacter=height markercharacterattrs=(weight=bold);
endlayout;
endgraph;
end;
run;
/*--Axis Options--*/
ods graphics / reset width=2.5in height=1.75in imagename='ClassTableAxis';
proc sgrender data=classTable template=ClassTableAxis;
format height weight 4.1;
run;