If your max tick value is 30 ,not 100, could try this one :
data have;
call streaminit(123);
do bp_status='High ','Normal ','Optimal';
do n=1 to 100;
if bp_status='High' then score=rand('integer',20,30);
else if bp_status='Normal' then score=rand('integer',10,20);
else score=rand('integer',0,10);
output;
end;
end;
run;
proc sort data=have;
by descending bp_status;
run;
/*calculate the length of box*/
proc summary data=have ;
by descending bp_status;
var score;
output out=q3(drop=_:) q3=q3;
run;
/*Make a dataset for customize legend*/
data legend;
set q3 end=last;
if last then q3=30;
_id='Blood Status';
lag_q3=lag(q3);
dif_q3=coalesce(dif(q3),q3);
if _n_=1 then text_value=q3/2;
else text_value=lag_q3+dif_q3/2;
run;
data want;
set have legend(rename=(bp_status=_bp_status));
run;
proc template;
define statgraph y2axis ;
begingraph;
layout lattice / rows=2 rowgutter=0 rowweights=(0.8 0.2) columndatarange=union;
layout overlay/ walldisplay=none YAXISOPTS=(display=(label tickvalues))
XAXISOPTS=( LINEAROPTS=(tickvaluelist=(0 5 10 15 20 25 30) )) ;
boxplot x=bp_status y=score/orient=horizontal group=bp_status
OUTLINEATTRS=(color=black) OUTLIERATTRS=(size=0) WHISKERATTRS=(color=black)
MEANATTRS=(size=0) MEDIANATTRS=(color=black);
endlayout;
layout overlay/walldisplay=none YAXISOPTS=(display=(tickvalues))
XAXISOPTS=( display=(ticks tickvalues)
LINEAROPTS=(tickvaluelist=(0 5 10 15 20 25 30) ));
BARCHARTPARM CATEGORY=_id response=dif_q3/group=_bp_status orient=horizontal
OUTLINEATTRS=(thickness=0) BASELINEATTRS=(thickness=0) GROUPORDER=DATA BARWIDTH=1;
TEXTPLOT x=text_value y=_id text=_bp_status /TEXTATTRS=(color=black size=10) POSITION=left CONTRIBUTEOFFSETS=none;
endlayout;
endlayout;
endgraph;
end;
run;
data dattrmap;
input id $ value $ fillcolor :$20. ;
datalines;
myid High CXDEEBF7
myid Normal CX9ECAE1
myid Optimal CX3182BD
;
run;
proc sgrender data=want template=y2axis dattrmap=dattrmap;
dattrvar bp_status="myid";
dattrvar _bp_status="myid";
run;
... View more