%let gpath='C:\';
%let dpi=200;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;
options debug=none;
/*--Generate data--*/
data noThreshold;
drop i;
do i=1 to 200;
x=0.88+3.2*ranuni(2);
y=1+1*ranuni(2);
output;
end;
run;
/*proc print; run;*/
/*--No Thresholding using GPLOT--*/
ods listing image_dpi=96;
goptions device=png xpixels=500 ypixels=300 border;
symbol v=dot h=2 c=black;
title;
proc gplot data=noThreshold;
plot y*x;
run;
/*--No Thresholding--*/
ods listing sge=on;
ods graphics / reset width=5in height=3in imagename='NoThreshold';
title 'No Thresholding';
proc sgplot data=noThreshold nocycleattrs;
scatter x=x y=y / markerattrs=(symbol=circlefilled size=10);
xaxis grid thresholdmin=1 thresholdmax=1;
yaxis grid;
run;
/*--With Thresholding--*/
ods graphics / reset width=5in height=3in imagename='WithThreshold';
title 'With Thresholding';
proc sgplot data=noThreshold nocycleattrs;
scatter x=x y=y / markerattrs=(symbol=circlefilled size=10);
xaxis grid;
yaxis grid;
run;
data heart;
length group $12;
set sashelp.heart(where=(ageatstart>60 and diastolic < 119 and
cholesterol > 200 and cholesterol < 340 ));
if cholesterol > 310 or cholesterol < 205 then clabel=cholesterol;
if diastolic > 114 or diastolic < 60 then dlabel=diastolic;
if mod(_n_,2) then do; xmiss=cholesterol; group='Diastolic'; end;
else do; ymiss=diastolic; group='Cholesterol'; end;
run;
/*proc print;run;*/
/*--Default behavior--*/
ods graphics / reset width=5in height=3in imagename='DefaultThreshold';
title 'Diastolic by Cholesterol for Age at Start > 60';
footnote j=l 'Default Thresholds';
proc sgplot data=heart nocycleattrs;
scatter x=cholesterol y=diastolic / datalabel=clabel datalabelattrs=graphdata2;
scatter x=cholesterol y=diastolic / datalabel=dlabel datalabelattrs=graphdata1 markerattrs=(size=0);
scatter x=xmiss y=ymiss / group=group name='a';
keylegend 'a'/ location=inside position=bottomright type=markercolor across=1 noborder;
xaxis grid;
yaxis grid;
run;
/*--X ThresholdMax = 1--*/
ods graphics / reset width=5in height=3in imagename='XThresholdMax';
title 'Diastolic by Cholesterol for Age at Start > 60';
footnote j=l 'X Threshold Max=1';
proc sgplot data=heart nocycleattrs noautolegend;
scatter x=cholesterol y=diastolic / datalabel=clabel datalabelattrs=graphdata2;
scatter x=cholesterol y=diastolic / datalabel=dlabel datalabelattrs=graphdata1 markerattrs=(size=0);
scatter x=xmiss y=ymiss / group=group name='a';
keylegend 'a'/ location=inside position=bottomright type=markercolor across=1 noborder;
xaxis grid thresholdmax=1;
yaxis grid;
run;
/*--Y ThresholdMax = 0--*/
ods graphics / reset width=5in height=3in imagename='YThresholdMin';
title 'Diastolic by Cholesterol for Age at Start > 60';
footnote j=l 'Y Threshold Max=0';
proc sgplot data=heart nocycleattrs noautolegend;
scatter x=cholesterol y=diastolic / datalabel=clabel datalabelattrs=graphdata2;
scatter x=cholesterol y=diastolic / datalabel=dlabel datalabelattrs=graphdata1 markerattrs=(size=0);
scatter x=xmiss y=ymiss / group=group name='a';
keylegend 'a'/ location=inside position=bottomright type=markercolor across=1 noborder;
xaxis grid thresholdmax=1;
yaxis grid thresholdmax=0;
run;
/*--Threshold Icon--*/
ods listing image_dpi=100;
ods graphics / reset width=2.7in height=1.8in imagename='ThresholdIcon';
title 'Diastolic by Cholesterol for Age at Start > 60';
footnote j=l 'Default Thresholds';
proc sgplot data=heart nocycleattrs;
scatter x=cholesterol y=diastolic / datalabel=clabel datalabelattrs=graphdata2;
scatter x=cholesterol y=diastolic / datalabel=dlabel datalabelattrs=graphdata1 markerattrs=(size=0);
scatter x=xmiss y=ymiss / group=group name='a';
keylegend 'a'/ location=inside position=bottomright type=markercolor across=1 noborder;
xaxis grid;
yaxis grid;
run;
title;
footnote;