%let gpath='.';
%let dpi=200;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;
ods output sgplot=sgplotdata(rename=(BOX_CHOLESTEROL_X_DEATHCAUSE___Y=Value
BOX_CHOLESTEROL_X_DEATHCAUSE__ST=Stat
BOX_CHOLESTEROL_X_DEATHCAUSE___X=Cat));
ods graphics / reset width=5in height=3in imagename='BoxPlot';
proc sgplot data=sashelp.heart;
vbox cholesterol / category=deathcause;
run;
data merged;
set sashelp.heart(keep=cholesterol deathcause)
sgplotdata(where=(value ne . and
stat in ('Q1' 'Q3' 'STD')));
run;
/*ods html;*/
/*proc print data=sgplotdata;run;*/
/*ods html close;*/
/*--Box with Stat Table Outside--*/
ods graphics / reset width=5in height=3in imagename='BoxStatOut';
proc sgplot data=merged;
vbox cholesterol / category=deathcause;
xaxistable value / x=cat class=stat;
xaxis display=(nolabel);
run;
/*--Box with Stat Table Inside--*/
ods graphics / reset width=5in height=3in imagename='BoxStatIn';
proc sgplot data=merged;
vbox cholesterol / category=deathcause;
xaxistable value / x=cat class=stat
location=inside;
xaxis display=(nolabel);
run;
/*--Box with Stat Table No Outliers--*/
ods graphics / reset width=5in height=3in imagename='BoxStatInNoOutliers';
proc sgplot data=merged;
vbox cholesterol / category=deathcause nooutliers;
xaxistable value / x=cat class=stat location=inside;
xaxis display=(nolabel);
run;
/*--Box with Stat Table Scatter--*/
ods graphics / reset width=5in height=3in imagename='BoxStatScatter';
proc sgplot data=merged;
vbox cholesterol / category=deathcause nooutliers nofill;
scatter x=deathcause y=cholesterol / jitter jitterwidth=0.4
markerattrs=(symbol=circlefilled size=5) transparency=0.95;
xaxistable value / x=cat class=stat location=inside;
xaxis display=(nolabel);
run;
/*--Group by Sex--*/
ods output sgplot=sgplotdataGroup(rename=(BOX_CHOLESTEROL_X_DEATHCAUSE___Y=Value
BOX_CHOLESTEROL_X_DEATHCAUSE__ST=Stat
BOX_CHOLESTEROL_X_DEATHCAUSE___X=Cat
BOX_CHOLESTEROL_X_DEATHCAUSE__GP=Grp));
proc sgplot data=sashelp.heart;
vbox cholesterol / category=deathcause group=sex;
run;
data mergedGroup;
set sashelp.heart(keep=cholesterol deathcause sex)
sgplotdataGroup(where=(value ne . and stat eq 'STD'));
run;
/*ods html;*/
/*proc print data=mergedGroup;run;*/
/*ods html close;*/
/*--Grouped Box with Stat Table Scatter--*/
ods graphics / reset attrpriority=color width=5in height=3in imagename='BoxStatScatterGroup';
proc sgplot data=mergedGroup;
label value='STD';
format value 5.2;
vbox cholesterol / category=deathcause group=sex nooutliers
nofill grouporder=ascending name='a';
scatter x=deathcause y=cholesterol / group=sex groupdisplay=cluster
grouporder=ascending jitter markerattrs=(symbol=circlefilled size=5)
transparency=0.95 clusterwidth=0.7;
xaxistable value / x=cat class=grp classdisplay=cluster colorgroup=grp location=inside classorder=ascending;
xaxis display=(nolabel);
keylegend 'a' / linelength=24;
run;
data mergedGroup2;
set sashelp.heart(keep=cholesterol deathcause sex)
sgplotdataGroup(where=(value ne . and stat in ('Q1' 'Q3' 'STD')));
if stat eq 'STD' then STD=value;
else if stat eq 'Q1' then Q1=value;
else if stat eq 'Q3' then Q3=value;
run;
/*ods html;*/
/*proc print data=mergedGroup2;run;*/
/*ods html close;*/
/*--Grouped Box with Multi Stat Table Scatter--*/
ods graphics / reset attrpriority=color width=5in height=3in imagename='BoxStatScatterGroupMulti';
proc sgplot data=mergedGroup2;
label value='STD';
format std 5.2 q1 q3 4.1;
vbox cholesterol / category=deathcause group=sex nooutliers
nofill grouporder=ascending name='a';
scatter x=deathcause y=cholesterol / group=sex groupdisplay=cluster
grouporder=ascending jitter
markerattrs=(symbol=circlefilled size=5)
transparency=0.95 clusterwidth=0.7;
xaxistable q1 / x=cat class=grp classdisplay=cluster colorgroup=grp location=inside classorder=ascending;
xaxistable q3 / x=cat class=grp classdisplay=cluster colorgroup=grp location=inside classorder=ascending;
xaxistable std / x=cat class=grp classdisplay=cluster colorgroup=grp location=inside classorder=ascending;
xaxis display=(nolabel);
keylegend 'a' / linelength=24;
run;
/**/
/*ods output sgplot=sgplotdata;*/
/*proc sgplot data=sashelp.heart;*/
/*vbox cholesterol / category=deathcause;*/
/*run;*/