%let gpath='.'; %let dpi=200; ods html close; ods listing style=htmlblue gpath=&gpath image_dpi=&dpi; /*--Abbreviate long death cause values--*/ data heart; set sashelp.heart; if deathcause='Cerebral Vascular Disease' then deathcause= 'CVD'; if deathcause='Coronary Heart Disease' then deathcause= 'CHD'; run; /*proc print;run;*/ /*--Compute the Mean and Median by sex--*/ proc means data=heart noprint; class deathcause; var cholesterol; output out=heartstat(where=(_type_ > 0) keep=deathcause mean median _type_) mean = mean median = median; run; /*proc print;run;*/ /*--Rearrange multi column to group--*/ data heartGroup; length Group $6; keep DeathCause Group Value; set heartstat; Group='Mean'; Value=Mean; output; Group='Median'; Value=Median; output; run; proc print;run; proc sort data=heartGroup; by group; run; ods html; proc print data=heartGroup;run; ods html close; /*--Make Anno data set--*/ data sganno; length Label $6 DrawSpace $12; drop DeathCause Group Value; set heartGroup end=last; by group; /*--Script out the Mean and Median polylines--*/ DrawSpace='DataValue'; LineThickness=1; if first.group then Function='PolyLine'; else Function='PolyCont'; if group='Mean' then LinePattern='Solid'; else LinePattern='Dash'; XC1=deathcause; Y1=Value; output; /*--Script out the Legend--*/ if last then do; DrawSpace='WallPercent'; Width=50; LinePattern='Solid'; Function='Line'; x1=80; y1=95; x2=90; y2=95; output; Function='Text'; x1=90; y1=95; Label='Mean'; anchor='left'; output; LinePattern='Dash'; Function='Line'; x1=80; y1=90; x2=90; y2=90; output; Function='Text'; x1=90; y1=90; Label='Median'; anchor='left'; output; end; run; /*proc print;run;*/ ods html; proc print data=sganno;run; ods html close; /*--Box plot with connect and group colors--*/ ods graphics / reset ANTIALIASMAX=5300 width=5in height=3in imagename='Box_Group_Multi_Connect_Anno_93'; title 'Cholesterol by Cause of Death'; proc sgplot data=heart sganno=sganno noautolegend; vbox cholesterol / category=deathcause group=deathcause ; xaxis display=(nolabel); run;