%let gpath='.'; %let dpi=200; ods html close; ods listing gpath=&gpath image_dpi=&dpi; /*--Get bin counts--*/ ods output sgpanel=dataSmall; ods graphics / reset imagename='HistPanel'; proc sgpanel data=sashelp.heart(where=(ageatstart>58 and deathcause ne 'Unknown')); panelby deathcause / layout=rowlattice rows=4 novarname; histogram cholesterol / scale=count binwidth=20; run; /*--Replicate data for scatter--*/ data turnipScatter; set dataSmall (rename=(BIN_CHOLESTEROL_SCALE_count_B__X=y BIN_CHOLESTEROL_SCALE_count_B__Y=max)); if max>0; do i=1 to max; output; end; run; /*--Create Turnip Graph--*/ ods graphics / reset width=5in height=3in imagename='TurnipScatter'; title 'Distribution of Cholesterol by DeathCause'; proc sgplot data=turnipScatter noautolegend; scatter x=deathcause y=y / jitter; xaxis display=(nolabel); run; /*--Get bin counts for full data--*/ ods output sgpanel=data; ods graphics / reset imagename='HistPanel'; proc sgpanel data=sashelp.heart(where=(deathcause ne 'Unknown')); panelby deathcause / layout=rowlattice rows=4 novarname; histogram cholesterol / scale=count binwidth=20; run; /*--Keep only non-zero bins--*/ data nonzero; set data (rename=(BIN_CHOLESTEROL_SCALE_count_B__X=y BIN_CHOLESTEROL_SCALE_count_B__Y=max)); if max>0; zero=0; run; /*--Make mirrored data for a HighLow plot--*/ data turnip; length label $40; set nonzero; where deathcause ne ''; by deathcause; if first.deathcause then label=deathcause; min=-max; zero=0; ylbl=-10; run; /*--Create Spark-Plug Graph--*/ ods graphics / reset width=5in height=3in imagename='TurnipPanelText'; title 'Distribution of Cholesterol by DeathCause'; proc sgpanel data=turnip noautolegend; panelby deathcause / novarname layout=columnlattice columns=4 noborder noheader; highlow y=y low=min high=max / type=bar barwidth=1 fillattrs=(color=lightgray) lineattrs=(color=black); colaxis display=none; rowaxis min=0 offsetmin=0.15 display=(noticks noline nolabel) grid; text y=y x=zero text=max / strip textattrs=(size=5); text y=ylbl x=zero text=label / strip splitpolicy=split position=bottom contributeoffsets=none; run; /*--Create Spark-Plug Graph--*/ ods graphics / reset width=5in height=3in imagename='TurnipPanel'; title 'Distribution of Cholesterol by DeathCause'; proc sgpanel data=turnip noautolegend; panelby deathcause / novarname layout=columnlattice columns=4 noborder noheader; highlow y=y low=min high=max / type=bar barwidth=1 fillattrs=(color=lightgray) lineattrs=(color=gray); colaxis display=none; rowaxis min=0 offsetmin=0.15 display=(noticks noline nolabel) grid; text y=ylbl x=zero text=label / strip splitpolicy=split position=bottom contributeoffsets=none; run; /*--Create Spark-Plug Graph--*/ ods graphics / reset width=5in height=3in imagename='TurnipPanelLine'; title 'Distribution of Cholesterol by DeathCause'; proc sgpanel data=turnip noautolegend; panelby deathcause / novarname layout=columnlattice columns=4 noborder noheader; highlow y=y low=min high=max / lineattrs=(color=black thickness=3); colaxis display=none; rowaxis min=0 offsetmin=0.15 display=(noticks noline nolabel) grid; text y=ylbl x=zero text=label / strip splitpolicy=split position=bottom contributeoffsets=none; run; /*--Create Violin Graph--*/ ods graphics / reset width=5in height=3in imagename='ViolinPanel'; proc sgpanel data=turnip noautolegend; panelby deathcause / novarname layout=columnlattice columns=4 noborder noheader; band y=y lower=min upper=max; colaxis display=none; rowaxis min=0 offsetmin=0.15 display=(noticks noline nolabel) grid; /* text y=y x=zero text=max / strip textattrs=(size=5);*/ text y=ylbl x=zero text=label / strip splitpolicy=split position=bottom contributeoffsets=none; run;