The SURFACEPLOTPARM
statement assumes that the Z response values have been provided for
a uniform X-Y grid. Missing Z values leave a “hole”
in the surface. The observations in the input data set should form
an evenly spaced grid of horizontal (X and Y) values and one vertical
(Z) value for each of these combinations. The observations should
be in sorted order of Y and X to obtain an accurate graph.
The G3GRID procedure
(requires a
SAS/GRAPH license) can be used to interpolate the necessary
values to produce a data set with nonmissing Z values for every combination
of X and Y. The G3GRID procedure can also smooth data with spline
interpolations. For further details, see the documentation for PROC
G3GRID in the
SAS/GRAPH: Reference.
Using PROC G3GRID, the
following code performs a Spline interpolation and generates this
figure:
data nums;
do i=1 to 30;
X=10*ranuni(33)-5;
Y=10*ranuni(35)-5;
Z=sin(sqrt(x*x+y*y));
output;
end;
run;
proc g3grid data=nums out=gridded;
grid y*x=z / spline
axis1=-5 to 5 by .1
axis2=-5 to 5 by .1;
run;
proc sort data=gridded; by y x; run;
proc template;
define statgraph g3grid_surface;
begingraph;
entrytitle "Spline Interpolation";
layout overlay3d;
surfaceplotparm x=x y=y z=z /
surfacetype=fill;
endlayout;
endgraph;
end;
run;
proc sgrender data=gridded template=g3grid_surface;
run;
The KDE procedure can
produce an output data set of gridded X-Y values where the Z value
is computed to be a Kernel Density Estimate of the distribution of
X and Y. For further details, see the documentation for PROC KDE in
the
SAS/STAT user’s guide.
Using PROC KDE on the
nums data generated in the previous example,
the following code computes a Kernel Density Estimate and generates
this figure:
/* use the nums data generated in the previous example */
proc kde data=nums;
bivar x y / ngrid=100
out=binned(rename=(value1=X value2=Y));
run;
proc sort data=binned; by y x;
label x="X" y="Y";
run;
proc template;
define statgraph kde_surface;
begingraph;
entrytitle "Kernel Density Estimate";
layout overlay3d;
surfaceplotparm x=x y=y z=density /
surfacetype=fill;
endlayout;
endgraph;
end;
run;
proc sgrender data=binned template=kde_surface;
run;
The SURFACEPLOTPARM
does not support the tooltips that are enabled by the IMAGEMAP= option
in the ODS GRAPHICS statement.