%let gpath='C:\'; %let dpi=200; ods html close; ods listing gpath=&gpath image_dpi=&dpi; /*--Compute mean city and highway mileage by origin and type--*/ proc means data=sashelp.cars(where=(type ne 'Hybrid')); class origin type; var mpg_city mpg_highway; output out=carmeans(where=(_type_ >2)) Mean(mpg_city mpg_highway) = City Highway; run; /*--Create additional variables--*/ data carmeans; label City='Mileage' Highway='Mileage'; format city highway 2.; set carmeans(keep=origin type city highway); if highway > 28 then Highcap='Filledarrow'; if city < 17 then Lowcap='Filledarrow'; Zero=0; run; /*--Simple Bar chart--*/ ods graphics / reset width=4in height=3in imagename='Bar'; title 'Highway Mileage by Origin and Type'; proc sgplot data=carmeans; vbarparm category=origin response=highway / group=type datalabel outlineattrs=graphoutlines dataskin=matte; xaxis display=(nolabel noticks); run; /*--Vertical Bar chart using HighLow--*/ ods graphics / reset width=4in height=3in imagename='HighLowBarVertZero'; title 'Highway Mileage by Origin and Type'; proc sgplot data=carmeans; highlow x=origin high=highway low=zero / group=type type=bar groupdisplay=cluster highlabel=highway lineattrs=graphoutlines dataskin=matte; xaxis display=(nolabel noticks); yaxis offsetmin=0; run; /*--Vertical HighLow Bar chart--*/ ods graphics / reset width=4in height=3in imagename='HighLowBarVert'; title 'City and Highway Mileage by Origin and Type'; proc sgplot data=carmeans; highlow x=origin high=highway low=city / group=type type=bar groupdisplay=cluster lowlabel=city highlabel=highway barwidth=0.75 clusterwidth=0.7 lineattrs=graphoutlines dataskin=matte; xaxis display=(nolabel noticks); run; /*--Horizontal HighLow Bar chart--*/ ods graphics / reset width=4in height=3in imagename='HighLowBarHorz'; title 'City and Highway Mileage by Origin and Type'; proc sgplot data=carmeans; highlow y=origin high=highway low=city / group=type type=bar groupdisplay=cluster lowlabel=city highlabel=highway barwidth=0.75 clusterwidth=0.8 lineattrs=graphoutlines dataskin=matte; xaxis display=(nolabel); yaxis display=(nolabel noticks) colorbands=even colorbandsattrs=(transparency=0.5); run; /*--Horizontal HighLow Bar chart Caps--*/ ods graphics / reset width=4in height=3in imagename='HighLowBarHorzCaps'; title 'City and Highway Mileage by Origin and Type'; proc sgplot data=carmeans; highlow y=origin high=highway low=city / group=type type=bar groupdisplay=cluster lowlabel=city highlabel=highway lowcap=lowcap highcap=highcap barwidth=1 clusterwidth=0.8 lineattrs=graphoutlines dataskin=matte; xaxis display=(nolabel); yaxis display=(nolabel noticks) colorbands=even colorbandsattrs=(transparency=0.5); run; /*--Horizontal HighLow Bar chart ClipCaps--*/ ods graphics / reset width=4in height=3in imagename='HighLowBarHorzClipCaps'; title 'City and Highway Mileage by Origin and Type'; proc sgplot data=carmeans; highlow y=origin high=highway low=city / group=type type=bar groupdisplay=cluster lowlabel=city highlabel=highway clipcap barwidth=1 clusterwidth=0.8 lineattrs=graphoutlines dataskin=matte; refline 28 / axis=x lineattrs=(pattern=dash); xaxis display=(nolabel) max=28 values=(12 to 30 by 4); yaxis display=(nolabel noticks) colorbands=even colorbandsattrs=(transparency=0.5); run; /*--Vertical HighLow Line Plot--*/ ods graphics / reset width=6in height=3in imagename='HighLowLinePlot'; title 'Monthly Stock Values'; proc sgplot data=sashelp.stocks(where=(stock eq 'IBM' and date > '01Jan2002'd)); highlow x=date high=high low=low; xaxis display=(nolabel); yaxis display=(nolabel); run; /*--Vertical HighLow Line Plot--*/ ods graphics / reset width=6in height=3in imagename='HighLowLinePlotAll'; title 'Monthly Stock Values'; proc sgplot data=sashelp.stocks(where=(stock eq 'IBM' and date > '01Jan2002'd)); highlow x=date high=high low=low / open=open close=close; xaxis display=(nolabel); yaxis display=(nolabel); run;