* Richard A. DeVenezia 6/21/2000; * animate an annotated G3D plot; %macro zhat (x,y); %local pi; %let pi = 3.1415926; sin(x/10*&pi)**2 + sin(y/10*&pi)**2 %mend; * evaluate a surface function over a grid; data zhat; do x = 0 to 10 by .5; do y = 0 to 10 by .5; z = %zhat(x,y); output; end; end; run; * create some fake data with z slightly different than zhat; data z; do n = 1 to 3 + int(15 * ranuni(0)); x = 11 * ranuni(0); y = 11 * ranuni(0); zhat = %zhat(x,y); z = zhat + 1.5 * ranuni(0) - .8; output; end; run; %macro tlp(x); trim(left(put(&x,4.))) %mend; data anno; set z; retain xsys ysys zsys '2'; length function color $8; * function = 'label'; * text = '(' || %tlp(x) || ',' || %tlp(y) || ',' || %tlp(z) || ')'; * output; if z < zhat then color = 'red'; else color = 'black'; function = 'symbol'; text = 'dot'; output; function = 'move'; output; z = zhat; function = 'draw'; output; run; title f=swiss h=10pct "Annotated G3D Plot"; footnote j=c f=courier "z^ = sin(x/10*PI)**2 + sin(y/10*PI)**2"; filename g3d_anim 'c:\temp\report\g3d.gif'; goptions device=gifanim hpos= vpos= xpixels= ypixels= hsize=4in delay=100; proc goptions;run; goptions goutmode=replace gsfmode=replace gsfname=g3d_anim hpos=44 vpos=21; proc g3d data=zhat anno=anno; plot y * x = z / grid xticknum=6 yticknum=6 zticknum=6 rotate=70 75 80 85 87 85 80 75 tilt=70 75 80 85 87 85 80 75 ; run; data _null_; file g3d_anim recfm=n mod; put '3B'x; run; goptions reset=all;