%let gpath='C:'; %let dpi=100; ods html close; ods listing style=htmlblue gpath=&gpath image_dpi=&dpi; /*--Car Mean Mileage--*/ proc means data=sashelp.cars(where=(type ne 'Hybrid')) noprint; class type origin; var mpg_city; output out=CarsMeanMileage mean=Mean median=Median q1=Q1 q3=Q3 p10=P10 p90=P90; run; /*--Trim the data, add Y value for label--*/ data CarsMeanMileage; set CarsMeanMileage(where=(_type_ eq 3)); drop _type_ _freq_; format mean 4.1; meanlabelpos=mean+0.75; run; /*--Make Regular Box--*/ ods graphics / reset width=5in height=3in imagename='VBox'; proc sgplot data=sashelp.cars(where=(type ne 'Hybrid')); vbox mpg_city / category=type group=origin grouporder=ascending; yaxis grid; xaxis display=(nolabel); run; /*--Make Custom Box plot using HighLow--*/ ods graphics / reset width=5in height=3in imagename='SGBoxParm'; proc sgplot data=CarsMeanMileage nocycleattrs; highlow x=type high=p90 low=p10 / group=origin groupdisplay=cluster clusterwidth=0.7; highlow x=type high=q3 low=median / group=origin type=bar groupdisplay=cluster grouporder=ascending clusterwidth=0.7 barwidth=0.7 name='a'; highlow x=type high=median low=q1 / group=origin type=bar groupdisplay=cluster grouporder=ascending clusterwidth=0.7 barwidth=0.7; scatter x=type y=mean / group=origin groupdisplay=cluster grouporder=ascending clusterwidth=0.7 markerattrs=(size=9); keylegend 'a'; yaxis grid; xaxis display=(nolabel); run; /*--HighLow Box Overlay with mean label--*/ ods graphics / reset width=5in height=3in imagename='SGBoxParmLabel'; proc sgplot data=CarsMeanMileage nocycleattrs; highlow x=type high=p90 low=q3 / group=origin groupdisplay=cluster clusterwidth=0.7; highlow x=type high=q1 low=p10 / group=origin groupdisplay=cluster clusterwidth=0.7; highlow x=type high=q3 low=median / group=origin type=bar groupdisplay=cluster grouporder=ascending clusterwidth=0.7 barwidth=0.7 transparency=0.5 name='a'; highlow x=type high=median low=q1 / group=origin type=bar groupdisplay=cluster grouporder=ascending clusterwidth=0.7 barwidth=0.7 transparency=0.5; scatter x=type y=mean / group=origin groupdisplay=cluster grouporder=ascending clusterwidth=0.7 markerattrs=(size=9); scatter x=type y=meanlabelpos / group=origin groupdisplay=cluster grouporder=ascending clusterwidth=0.7 markerchar=mean markercharattrs=(size=8 weight=bold); keylegend 'a'; yaxis grid; xaxis display=(nolabel); run;