%let gpath='.'; %let dpi=200; ods html close; ods listing gpath=&gpath image_dpi=&dpi; /*--Create Funnel Data--*/ data funnel; input Level Value; low=50-value/2; high=50+value/2; mid=50; datalines; 1 100 2 90 3 75 4 50 5 30 6 15 7 10 ; run; /*ods html;*/ /*proc print;run;*/ /*ods html close;*/ /*--Funnel Bar Chart--*/ ods graphics / reset width=5in height=3in imagename='Funnel_Bar'; proc sgplot data=funnel nowall noborder noautolegend; highlow y=level low=low high=high / type=bar dataskin=matte; text y=level x=mid text=value / textattrs=(size=12) strip; yaxis reverse display=none; xaxis display=none; run; proc sort data=funnel out=funnel2; by descending value; run; /*ods html;*/ /*proc print;run;*/ /*ods html close;*/ /*--Create Polygon data for Funnel--*/ data funnel3; keep x y id val mid yval; retain thk 0.48 off 0.25; retain prevLow prevHigh prevLevel prevValue id val yval; set funnel2 end=last; if _n_ = 1 then do; prevLow=low; prevHigh=high; prevLevel=level; prevValue=value; /*--Script first node top vertices--*/ id=Level; Val=Value; yval=id-off; x=prevLow; y=Level-thk; output; x=prevHigh; y=Level-thk; output; end; else do; /*--Script previous node bottom vertices--*/ x=high; y=prevLevel+thk; output; x=low; y=prevLevel+thk; output; /*--Script this node top vertices--*/ id=Level; Val=Value; yval=id-off; x=low; y=Level-thk; output; x=high; y=Level-thk; output; prevLow=low; prevHigh=high; prevLevel=level; prevValue=value; end; if last then do; /*--Script last node bottom vertices--*/ x=high; y=prevLevel+thk; output; x=low; y=prevLevel+thk; output; end; run; /*ods html;*/ /*proc print;run;*/ /*ods html close;*/ /*--Funnel Bar Chart--*/ ods graphics / reset width=5in height=3in imagename='Funnel_Poly'; proc sgplot data=funnel3 nowall noborder noautolegend; polygon x=x y=y id=id / label=val fill dataskin=sheen; yaxis reverse display=none; xaxis display=none; run; /*--Define a Range Attr Map--*/ data rangeMap; id='a'; min=0; max=100; colormodel2='LightBlue'; colormodel1='DarkBlue'; output; run; /*--Funnel Bar Chart with Range Attr Map--*/ ods graphics / reset width=5in height=3in imagename='Funnel_Poly_Range'; proc sgplot data=funnel3 nowall noborder noautolegend rattrmap=rangeMap; polygon x=x y=y id=id / fill dataskin=sheen colorresponse=val rattrid=a; text x=mid y=yval text=val / backlight=0.25; yaxis reverse display=none; xaxis display=none; run;