%let gpath=C:\; %let dpi=200; %let w=4in; %let h=3.2in; ods html close; ods listing gpath="&gpath" image_dpi=&dpi; /*--Make up some data--*/ proc means data=sashelp.cars(where=(Type in ('Sedan', 'Sports', 'SUV'))) noprint; class type origin; var mpg_city; output out=cars(where=(_type_ > 2)) n=Count; ; run; proc print;run; /*--Default Bubble Plot--*/ ods graphics / reset width=4in height=2.5in imagename='Bubble_Default'; title 'Frequency of Car Types (Relative)'; proc sgplot data=cars noborder; bubble x=type y=origin size=count / fillattrs=graphdata1 bradiusmin=5px bradiusmax=35px datalabel=count datalabelpos=center; xaxis grid display=(noline noticks nolabel); yaxis grid display=(noline noticks nolabel); run; /*--Proportional Bubble Plot--*/ ods graphics / reset width=4in height=2.5in imagename='Bubble_Proportional'; title 'Frequency of Car Types (Relative - Proportional)'; proc sgplot data=cars noborder; bubble x=type y=origin size=count / fillattrs=graphdata2 proportional bradiusmin=5px bradiusmax=35px proportional datalabel=count datalabelpos=center; xaxis grid display=(noline noticks nolabel); yaxis grid display=(noline noticks nolabel); run; /*--Make up some data--*/ data bubble; input id x y size; datalines; 1 2 2 1.5 2 6 3 1 3 4 5 0.75 ; run; /*--Equated Bubble Plot--*/ ods graphics / reset width=4in height=2.5in imagename='Bubble_Eq'; title 'Proportional Bubbles with Relative Size'; proc sgplot data=bubble aspect=0.6 noborder; bubble x=x y=y size=size / proportional datalabel=size datalabelattrs=(size=8) datalabelpos=center fillattrs=graphdata3; xaxis values=(0 to 10 by 1) grid display=(noline noticks nolabel); yaxis values=(0 to 6 by 1) grid display=(noline noticks nolabel); run; /*--Equated Abs Bubble Plot--*/ ods graphics / reset width=4in height=2.5in imagename='Bubble_Eq_Abs'; title 'Equated Bubbles with Absolute Size'; proc sgplot data=bubble aspect=0.6 noborder; bubble x=x y=y size=size / proportional absscale transparency=0.3 fillattrs=graphdata4 datalabel=size datalabelpos=center datalabelattrs=(size=10); xaxis values=(0 to 10 by 1) grid display=(noline noticks nolabel); yaxis values=(0 to 6 by 1) grid display=(noline noticks nolabel); run; /*--Equated Abs Bubble Plot--*/ ods graphics / reset width=4in height=2.5in imagename='Bubble_Eq_Abs_Grp'; title 'Non-Equated Bubbles with Absolute Size and Group'; proc sgplot data=bubble noborder noautolegend; bubble x=x y=y size=size / proportional absscale transparency=0.3 dataskin=pressed datalabel=size datalabelpos=center group=id datalabelattrs=(size=10); xaxis values=(0 to 8 by 1) grid display=(noline noticks nolabel); yaxis values=(0 to 6 by 1) grid display=(noline noticks nolabel); run;