%let gpath='C:\';
%let dpi=200;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;
%macro Spiral (Cycles=2, Height=0.5, Step=15, A=0, Thickness=1, Vector=No, Arrow=No, Sine=No);
/*--Make Spiral data set--*/
data _spiral;
b=1/(360*&Cycles);
pi=constant("PI");
do theta=0 to &Cycles*360 by &Step;
res=&Height;
%if %upcase(&Sine) eq YES %then %do;
res=&Height*abs(sin(5*theta*pi/180));
%end;
h=res/&Cycles;
r=&A+b*theta;
x=r*cos(theta*pi/180);
y=r*sin(theta*pi/180);
if mod(theta, &Step)= 0 then do;
if r > 0 then do;
cx=-x/r; cy=-y/r;
x2=x+h*cx; y2=y+h*cy;
end;
else do;
cx=.; cy=.;
x2=x; y2=y;
end;
end;
else call missing (cx, cy, x2, y2);
output;
end;
%let max=%sysevalf(&A+1);
run;
/*--Make Spiral graph--*/
proc sgplot data=_spiral pad=0 noautolegend;
series x=x y=y / lineattrs=(thickness=&thickness);
%if %upcase(&Vector) eq YES %then %do;
vector x=x2 y=y2 / xorigin=x yorigin=y
%if %upcase(&Arrow) eq NO %then %do; NoArrowHeads; %end;
;
%end;
xaxis min=-&max max=&max grid display=none;
yaxis min=-&max max=&max grid display=none;
run;
%mend;
options mautosource mprint mlogic;
title;
ods graphics / reset width=4in height=4in imagename='Spiral_N1';
%Spiral(Cycles=1, A=0, Thickness=2);
ods graphics / reset width=4in height=4in imagename='Spiral_N1_A';
%Spiral(Cycles=1, A=0.25, Thickness=2);
ods graphics / reset width=4in height=4in imagename='Spiral_N2';
%Spiral(Cycles=2, A=0.5, Thickness=2);
ods graphics / reset width=4in height=4in imagename='Spiral_N2_V';
%Spiral(Cycles=2, A=0.5, Vector=Yes, Arrow=Yes, Thickness=2);
ods graphics / reset width=4in height=4in imagename='Spiral_N3_V';
%Spiral(Cycles=3, A=0.5, Vector=Yes, Arrow=Yes, Thickness=2);
ods graphics / reset width=4in height=4in imagename='Spiral_N3_VS5';
%Spiral(Cycles=3, A=0.5, Vector=Yes, Arrow=No, Thickness=2, Step=2, Sine=Yes);