%sp_plota ---------------------------------------------------------------------- Create an animated 3 dimensional plot of a regression surface which rotates around its y axis Description The %sp_plota macro will create an animated 3 dimensional plot of a regression surface based on the coefficients from two predictors in a regression equation. The graph can be saved as a .gif file and used in a web page. The individual plots that make up the animated gif can be viewed individually in the graph window of SAS. The code for this macro should end in a semicolon in order to avoid unnecessary error messages in the log file. Syntax %sp_plota(outfile="c:\sp_plota.gif", data=_spinplt, x1lo=-10, x1hi=10, x1by=1, x2lo=-10, x2hi=10, x2by=1, cons=0, bx1=0, bx2=0, bx1x2=0, bx1x1=0, bx2x2=0, bx1x1x2=0, bx1x2x2=0, dev=gif373, title=Spin Plot, title2 = " ", cmd=plot, plot=, gopt=, ang_lo=0, ang_hi=360, ang_by=10); _spinplt - name of dataset where data created to be plotted in graph is saved x1lo - the minimum value of the range of x1 x1hi - the maximum value of the range of x1 x1by - the spacing of the grid of the regression surface x2lo - the minimum value of the range of x2 x2hi - the maximum value of the range of x2 x2by - the spacing of the grid of the regression surface const - the value of the constant in the regression function bx1 - the value of the coefficient of x1 in the regression function bx2 - the value of the coefficient of x2 in the regression function bx1x2 - the value of the coefficient of x1*x2 in the regression function bx1x1 - the value of the coefficient of x1*x1 in the regression function bx2x2 - the value of the coefficient of x2*x2 in the regression function bx1x1x2 - the value of the coefficient of x1*x1*x2 in the regression function bx1x2x2 - the value of the coefficient of x1*x2*x2 in the regression function outfile - saves the graph as a .gif file with the given name data - saves the data with the given name dev - specifies the graphic device used title - the title displayed at the top of the graph title2 - the second title displayed at the top of the graph the default is to display the regression function used to generate the graph, to repress this secondary title let title2= cmd - specifies if the graph is a plot (the data points define a surface) or a scatter plot (represents each data point with a specified shape, the default is a pyramid) plot - specifies other options for the graph, the options available will depend on whether cmd was specified as scatter or plot (plot is the default) gopt - specifies other goptions which can modify the detailed options on the size, color or the style of the plot ang_lo - the starting angle of the rotation of the plot ang_hi - the ending angle of the rotation of the plot ang_by - the spacing of the angles by which the plot rotates Examples %sp_plota(outfile='c:\sp_plota1.gif', bx1=-2, bx1x2=-1 ); %sp_plota(outfile='c:\sp_plota2.gif', title2= , cons=1, bx1=-2, bx2=1.7, bx1x2=-.5); %sp_plota(outfile='c:\sp_plota3.gif', cons=1, bx1=-2, bx2=1.7, bx1x2=-.5, x1lo=-5, x1hi=5, x2lo=-4, x2hi=4); %sp_plota(outfile='c:\sp_plota4.gif', cons=1, bx1=-2, bx2=1.7, bx1x2=-.5, plot=grid, title=Great Plot!, ang_by=40, gopt= delay=15); %sp_plota(outfile='c:\sp_plota5.gif', bx1=-2, bx2=1.7, bx1x2=-.5, title=Great Plot!, ang_by=40, plot= zmin=-12 zmax=18 grid ); %sp_plota(outfile='c:\sp_plota6.gif', bx1=-2, bx2=1.7, bx1x2=.5, plot= grid ctop=cyan cbottom=blue caxis=green); %sp_plota(outfile='c:\sp_plota7.gif', bx1=-2, bx1x2=-.5 , cmd=scatter, plot= noneedle grid shape='balloon' size=.6); %sp_plota(outfile='c:\sp_plota8.gif', bx1=-2, bx1x2=-.5 , cmd=scatter, plot= noneedle shape='spade' size=.4, gopt = border); %sp_plota(outfile='c:\sp_plota9.gif', bx1=1, bx2=-2, bx1x1x2=.1); Author Michael Mitchell mnm@ucla.edu UCLA Academic Technology Services Statistical Consulting Group Also See See a complete example in http://www.ats.ucla.edu/stat/sas/examples/aw/example_graphs.htm http://www.ats.ucla.edu/stat/sas/teach/reg_int/reg_int_cont.htm For more details about the cmd, plot and gopt options please refer to following sections in the SAS Manuals http://sasdocs.ats.ucla.edu/gref/z3d-plot.htm http://sasdocs.ats.ucla.edu/gref/zscatter.htm http://sasdocs.ats.ucla.edu/gref/zonschap.htm Also see the macro itself from http://www.ats.ucla.edu/stat/sas/macros/sp_plota.sas.txt Also see the books (http://www.ats.ucla.edu/stat/books/ ) Multiple Regression: Testing and Interpreting Interactions by Leona S. Aiken and Steven G. West Interaction Effects in Multiple Regression by James Jaccard, Robert Turrisi and Choi K. Wan