data cholesterol; keep deathcause cholesterol; set sashelp.heart; if deathcause ne ''; run; * first I'm just generating an index for your earlier dataset so that I don't have to create a dataset sorted by deathcause; proc datasets library=work; modify cholesterol; index create deathcause; run; quit; ods html close; ods listing; * kde stands for kernel desnity estimation and the procedure does just that; proc kde data = cholesterol; by deathcause; univar cholesterol (gridl=0 gridu=500) / NGRID=51 unistats percentiles plots=none /*(plots=(density HISTDENSITY)*/ out = chol_dens (rename=(value=cholesterol) drop=var); run; data chol_den_2; set chol_dens; mirror=-density; zero=0; run; %let gpath='C:\'; %let dpi=200; ods listing gpath=&gpath image_dpi=&dpi; /*--Vertical Violin--*/ ods graphics / reset width=7in height=4in imagename='Interval_Violin_Vert'; title 'Violin Plot of Cholesterol Densities by Death Cause'; proc sgpanel data=chol_den_2 nocycleattrs; panelby deathcause / layout=columnlattice onepanel novarname noborder colheaderpos=bottom; band y=cholesterol upper=density lower=mirror / fill outline; rowaxis label='Cholesterol' grid; colaxis display=none; run; /*--Vertical Violin HighLow--*/ ods graphics / reset width=7in height=4in imagename='Violin_HighLow_Vert'; title 'Violin Plot of Cholesterol Densities by Death Cause'; proc sgpanel data=chol_den_2 nocycleattrs; panelby deathcause / layout=columnlattice onepanel novarname noborder colheaderpos=bottom; highlow y=cholesterol high=density low=mirror / lineattrs=(thickness=4) transparency=0.5; rowaxis label='Cholesterol' grid; colaxis display=none; run; /*--Vertical Half Violin--*/ ods graphics / reset width=7in height=4in imagename='Band_Vert'; title 'Band Plot of Cholesterol Densities by Death Cause'; proc sgpanel data=chol_den_2 nocycleattrs; panelby deathcause / layout=columnlattice onepanel novarname noborder colheaderpos=bottom; band y=cholesterol upper=density lower=zero / fill outline; rowaxis label='Cholesterol' grid; colaxis display=(nolabel) grid valueattrs=(size=6); run; /*--Vertical Half Violin HighLow--*/ ods graphics / reset width=7in height=4in imagename='HighLow_Vert'; title 'Needle Plot of Cholesterol Densities by Death Cause'; proc sgpanel data=chol_den_2 nocycleattrs; panelby deathcause / layout=columnlattice onepanel novarname noborder colheaderpos=bottom; highlow y=cholesterol high=density low=zero / lineattrs=(thickness=4) transparency=0.5; rowaxis label='Cholesterol' grid; colaxis display=(nolabel) grid valueattrs=(size=6); run;