options cmplib=sasuser.funcs; %let gpath=C:\Work\Blogs\Graphically Speaking\2018\Post_06_Apr_18_3D_Waterfall_Macro; %let dpi=300; proc format; value res 0='1.0 mg' 1='2.0 mg' 2='3.0 mg' 3='4.0 mg' 4='3.0 F6 mg' 5='4.0 F6 mg'; run; /*--Create some data--*/ data tumor; format Drug res.; length Code $6; do i=1 to 20; Response=100*(ranuni(3)-0.7); Duration=50*ranuni(3); Dropped=.; if ranuni(3) > 0.6 then Dropped=duration-5; Drug=floor(6*ranuni(3)); if ranuni(3) > 0.7 then Code='FL'; else Code='DLBCL'; codeloc=ifn(response > 0, 0, response); output; end; run; /*--Sort by descending response--*/ proc sort data=tumor out=tumor; by descending Response; run; data tumorsorted; set tumor; j=_n_; run; ods html; proc print;run; ods html close; /*--Define Attributes map for walls and axes--*/ data attrmap; length ID $ 9 value $10 fillcolor $ 10 show $8; id='Resp'; value='1.0 mg'; fillcolor='white'; show='Attrmap'; output; id='Resp'; value='2.0 mg'; fillcolor='cxffffc0'; show='Attrmap'; output; id='Resp'; value='3.0 mg'; fillcolor='cxf0d0a0'; show='Attrmap'; output; id='Resp'; value='4.0 mg'; fillcolor='orange'; show='Attrmap'; output; id='Resp'; value='3.0 F6 mg'; fillcolor='cxff7f00'; show='Attrmap'; output; id='Resp'; value='4.0 F6 mg'; fillcolor='red'; show='Attrmap'; output; run; ods _all_ close; ods listing gpath="&gpath" image_dpi=&dpi; /*--2D Tumor Response and Duration Graph--*/ Title 'Tumor Response and Duration'; ods graphics / reset attrpriority=color width=4in height=3in imagename="WaterFall2D"; proc sgplot data=tumorsorted noautolegend dattrmap=attrmap; styleattrs axisextent=data; vbarparm category=j response=duration / fillattrs=graphdata1 dataskin=pressed y2axis name='d'; vbarparm category=j response=response / group=drug dataskin=pressed name='r' attrid=Resp; scatter x=j y=dropped / y2axis markerattrs=(symbol=diamondfilled size=5) filledoutlinedmarkers markerfillattrs=(color=gold) name='c'; text x=j y=codeloc text=code / rotate=90 position=left textattrs=(size=6); yaxis offsetmax=0.5 labelpos=datacenter grid display=(noline noticks); y2axis offsetmin=0.55 labelpos=datacenter grid display=(noline noticks); xaxis display=none colorbands=odd colorbandsattrs=(transparency=0.3); keylegend 'r' / position=bottomleft location=inside across=1 valueattrs=(size=4) noborder; keylegend 'c' / position=topright location=inside valueattrs=(size=4) noborder; run;