%let gpath='.'; %let dpi=200; ods listing gpath=&gpath image_dpi=&dpi; ods html close; /*--Macro by Perry Watts--*/ %macro RGBHex(rr,gg,bb); %sysfunc(compress(CX%sysfunc(putn(&rr,hex2.)) %sysfunc(putn(&gg,hex2.)) %sysfunc(putn(&bb,hex2.)))) %mend RGBHex; data Tach; length lbl1 lbl2 vlbl $5; pi=constant ("PI"); /*--Dial background fill--*/ start=0; end=360; step=2; off=90; ro=100; pid=1; do i=start to end+step by step; xp=(ro+2)*cos((i+off)*pi/180); yp=-(ro+2)*sin((i+off)*pi/180); output; end; /*--Inner Green segment, tick and tick value positions--*/ pid=.; x1=.; y1=.; group=1; startAngle=40; start=startAngle; end=200; step=2; off=90; r=90; r2=80; rlbl=70; do i=start to end by step; x2=r*cos((i+off)*pi/180); y2=-r*sin((i+off)*pi/180); if mod(i,20) = 0 then do; x3=r2*cos((i+off)*pi/180); y3=-r2*sin((i+off)*pi/180); xlbl=rlbl*cos((i+off)*pi/180); ylbl=-rlbl*sin((i+off)*pi/180); if mod(i,40) = 0 then lbl1=put((i-startAngle)/4,2.0); end; else call missing (x3, y3, lbl1); output; end; /*--Inner yellow segment, tick and tick value positions--*/ start=200; end=240; group=2; do i=start to end by step; x2=r*cos((i+off)*pi/180); y2=-r*sin((i+off)*pi/180); if mod(i,20) = 0 then do; x3=r2*cos((i+off)*pi/180); y3=-r2*sin((i+off)*pi/180); xlbl=rlbl*cos((i+off)*pi/180); ylbl=-rlbl*sin((i+off)*pi/180); if mod(i,40) = 0 then lbl1=put((i-startAngle)/4,2.0);; end; else call missing (x3, y3, lbl1); output; end; /*--Inner red segment, tick and tick value positions--*/ start=240; end=320; group=3; do i=start to end by step; x2=r*cos((i+off)*pi/180); y2=-r*sin((i+off)*pi/180); if mod(i,20) = 0 then do; x3=r2*cos((i+off)*pi/180); y3=-r2*sin((i+off)*pi/180); xlbl=rlbl*cos((i+off)*pi/180); ylbl=-rlbl*sin((i+off)*pi/180); if mod(i,40) = 0 then lbl1=put((i-startAngle)/4,2.0);; end; else call missing (x3, y3, lbl1); output; end; /*--Value--*/ call missing (x1, y1, x2, y2, x3, y3, xlbl, ylbl, lbl1 ); value=45; vlbl=put(value,2.0); xv=0; yv=-75; output; /*--Needle--*/ xn1=0; yn1=0; xn2=r*cos((4*value+startAngle+off)*pi/180); yn2=-r*sin((4*value+startAngle+off)*pi/180); output; /*--Hub--*/ xh=0; yh=0; output; run; /*--Back Dial--*/ %let Ring=; /*--Reflection Map--*/ %let Refl=; ods graphics / reset noscale scalemarkers=off attrpriority=color noborder width=3in height=3in imagename='KPI_Dial_Pastel_1_45'; proc sgplot data=tach aspect=1 nocycleattrs noautolegend noborder subpixel; symbolimage name=Ring image="&Ring" / voffset=-0.01; symbolimage name=Refl image="&Refl" / voffset=0.0; styleattrs datacontrastcolors=(lightgreen yellow red) wallcolor=white backcolor=white; /*--Dial--*/ scatter x=xh y=yh / markerattrs=(symbol=Ring size=2.5in); /*--Fill--*/ polygon id=pid x=xp y=yp / fillattrs=(color=%rgbhex(200, 200, 200)) fill nooutline; /*--Tick marks--*/ vector x=x2 y=y2 / xorigin=x3 yorigin=y3 noarrowheads; /*--Value Ring--*/ series x=x2 y=y2 / group=group lineattrs=(thickness=8 color=black); series x=x2 y=y2 / group=group lineattrs=(thickness=6); /*--Tick values--*/ text x=xlbl y=ylbl text=lbl1 / position=center textattrs=(size=10); /*--Display value--*/ text x=xv y=yv text=vlbl / position=center textattrs=(size=16pt weight=normal); /*--Display Needle--*/ vector x=xn2 y=yn2 / xorigin=xn1 yorigin=yn1 lineattrs=(thickness=2) arrowheadshape=barbed; /*--Display Hub--*/ scatter x=xh y=yh / markerattrs=(size=20 symbol=circlefilled color=gray) filledoutlinedmarkers dataskin=pressed markerfillattrs=(color=silver) markeroutlineattrs=(thickness=3); /*--Reflections--*/ scatter x=xh y=yh / markerattrs=(symbol=Refl size=2in) transparency=0.3; xaxis display=none min=-132 max=132 offsetmin=0.05 offsetmax=0.05; yaxis display=none min=-132 max=132 offsetmin=0.05 offsetmax=0.05; run;