ods html close; %let gpath=C:\; %let w=5in; %let h=3in; %let dpi=200; ods listing gpath="&gpath" image_dpi=&dpi; /*--Compute Cholesterol by deathcause and sex--*/ proc means data=sashelp.heart noprint; class deathcause sex; var cholesterol; output out=heart_group(where=(_type_ > 2)) Mean=MeanChol; run; /*--Compute Cholesterol by deathcause--*/ proc means data=sashelp.heart noprint; class deathcause; var cholesterol; output out=heart(where=(_type_ > 0)) Mean=MeanChol; run; /*--Set label, format and add size variable--*/ data heart_group; set heart_group; label meanchol='Mean Cholesterol'; format meanchol 3.0; keep deathcause sex meanchol size; size=10; run; /*--Set label, format and add size variable--*/ data heart; set heart; label meanchol='Mean Cholesterol'; format meanchol 3.0; keep deathcause meanchol size; size=10; run; /*--Default Needle--*/ ods listing style=htmlblue; ods graphics / reset width=5in height=3in imagename='Needle'; title 'Mean Cholesterol by Death Cause'; proc sgplot data=heart; needle x=deathcause y=meanchol / baselineattrs=(thickness=0) datalabel; xaxis display=(nolabel noticks); run; /*--Discrete Needle--*/ ods listing style=htmlblue; ods graphics / reset width=5in height=3in imagename='Needle_Discrete'; title 'Mean Cholesterol by Death Cause'; proc sgplot data=heart(where=(deathcause ne 'Other')) noautolegend noborder; needle x=deathcause y=meanchol / group=deathcause groupdisplay=cluster lineattrs=graphdatadefault baselineattrs=(thickness=0) datalabel datalabelpos=top; xaxis display=(nolabel noticks); yaxis offsetmin=0 display=(nolabel noticks noline) grid; run; /*--Vert Lollipop--*/ ods listing style=htmlblue; ods graphics / reset width=5in height=3in imagename='Lollipop_Vert'; title 'Mean Cholesterol by Death Cause'; proc sgplot data=heart(where=(deathcause ne 'Other')) noautolegend noborder; needle x=deathcause y=meanchol / group=deathcause groupdisplay=cluster lineattrs=(thickness=2 color=gray) baselineattrs=(thickness=0); bubble x=deathcause y=meanchol size=size / bradiusmin=16 datalabel datalabelpos=center; xaxis display=(nolabel noticks); yaxis offsetmin=0 display=(nolabel noticks noline) grid; run; /*--Vert Lollipop group--*/ ods listing style=htmlblue; ods graphics / reset width=5in height=3in imagename='Lollipop_Vert_Group'; title 'Mean Cholesterol by Death Cause'; proc sgplot data=heart_group (where=(deathcause ne 'Other')) noborder; styleattrs datacolors=(cxefafaf cxafafef) datacontrastcolors=(red blue); needle x=deathcause y=meanchol / group=sex groupdisplay=cluster clusterwidth=0.6 lineattrs=(thickness=2) baselineattrs=(thickness=0); scatter x=deathcause y=meanchol / group=sex groupdisplay=cluster clusterwidth=0.6 markerattrs=(symbol=circlefilled size=28) filledoutlinedmarkers datalabel datalabelpos=center datalabelattrs=(color=white) name='a'; xaxis display=(nolabel noticks); yaxis offsetmin=0 display=(nolabel noticks noline) grid; keylegend 'a' / type=markercolor; run; /*--Vert Lollipop group offset--*/ ods listing style=htmlblue; ods graphics / reset width=5in height=3in imagename='Lollipop_Vert_Group_2'; title 'Mean Cholesterol by Death Cause'; proc sgplot data=heart_group (where=(deathcause ne 'Other')) noborder; styleattrs datacolors=(cxefafaf cxafafef) datacontrastcolors=(red blue); needle x=deathcause y=meanchol / group=sex groupdisplay=cluster clusterwidth=0.34 lineattrs=(thickness=2) baselineattrs=(thickness=0); scatter x=deathcause y=meanchol / group=sex groupdisplay=cluster markerattrs=(symbol=circlefilled size=32) filledoutlinedmarkers datalabel datalabelpos=center name='a' dataskin=sheen; xaxis display=(nolabel noticks); yaxis offsetmin=0 display=(nolabel noticks noline) grid; keylegend 'a' / type=markercolor; run; /*--Horz Lollipop group--*/ ods listing style=htmlblue; ods graphics / reset width=4in height=4in imagename='Lollipop_Horz_Group'; title 'Mean Cholesterol by Death Cause'; proc sgplot data=heart_group (where=(deathcause ne 'Other')) noborder; styleattrs datacolors=(cxefafaf cxafafef) datacontrastcolors=(red blue); hbarparm category=deathcause response=meanchol / group=sex groupdisplay=cluster clusterwidth=0.25 barwidth=0.1 baselineattrs=(thickness=0); scatter y=deathcause x=meanchol / group=sex groupdisplay=cluster markerattrs=(symbol=circlefilled size=24) filledoutlinedmarkers name='a' dataskin=sheen; text y=deathcause x=meanchol text=meanchol / group=sex groupdisplay=cluster; xaxis offsetmin=0 display=(nolabel noticks noline) grid; yaxis display=(nolabel noticks noline) fitpolicy=split; keylegend 'a' / type=markercolor; run;