Procedure features:
G3GRID statement options:
OUT=
GRID statement options:
AXIS1=
AXIS2=
Other features:
DATA step
G3D procedure
Sample library member: GTGDEFIN
This example demonstrates the default interpolation method that is used by the GRID statement. The example first generates a scatter plot of random data to show the concentration of data values before processing with the G3GRID procedure. The original data do not contain enough combinations of x , y , and z values to generate a surface plot with the G3D procedure, or a contour plot with the GCONTOUR procedure.
The example then runs the G3GRID procedure to interpolate additional x , y , and z values. Because no interpolation method is specified, the default interpolation method is used. The resulting output data set is used as input to the G3D procedure, which generates the surface plot shown in the following output.
Assign the libref and set the graphics environment.
libname reflib ' SAS-data-library '; goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftext=swiss ftitle=swissb htitle=6 htext=3;
Create data set. REFLIB.NUMS uses a set of randomly sampled points to create the data used in this and all remaining examples in this chapter.
data reflib.nums; keep x y z; 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;
Define title and footnote.
title 'Scatter Plot of NUMS Data Set'; footnote j=r 'GTGDEFIN(a)';
Generate the scatter plot.
proc g3d data=reflib.nums; scatter y*x=z; run;
Process points with PROC G3GRID. OUT= on G3GRID specifies a name for a temporary output data set. GRID specifies the variables Y*X=Z for the output data set. AXIS@@@ 1
proc g3grid data=reflib.nums out=default; grid y*x=z / axis1=-5 to 5 by .5 axis2=-5 to 5 by .5; run;
Define new title and footnote.
title 'Surface Plot after Default Interpolation'; footnote j=r 'GTGDEFIN(b)';
Generate a surface plot. The G3D procedure uses as its input data set the G3GRID procedure s output data set.
proc g3d data=default; plot y*x=z; run; quit;
Procedure features:
GRID statement options:
SMOOTH=
SPLINE
Data set: REFLIB.NUMS (see Example 1 on page 1336)
Sample library member: GTGSISS
This example extends Example 1 on page 1336 to specify a spline interpolation method on the GRID statement. The output data set, when used in PROC G3D, generates a smoother surface plot than the surface plot that results from the default interpolation.
This example then specifies a smoothed spline interpolation method on the GRID statement. As shown by the following output, the resulting surface plot is smoother still.
Assign the libref and set the graphics environment.
libname reflib SAS-data-library ; goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftext=swiss ftitle=swissb htitle=5 htext=3;
Define title and footnote.
title Surface Plot After Spline Interpolation; footnote j=r GTGSISS(a);
Process points with PROC G3GRID. SPLINE specifies the bivariate spline method for the data set interpolation.
proc g3grid data=reflib.nums out=spline; grid y*x=z / spline axis1=-5 to 5 by .5 axis2=-5 to 5 by .5; run;
Generate a surface plot.
proc g3d data=spline; plot y*x=z ; run;
Define title and footnote for second plot.
title Surface Plot After Smoothed Spline Interpolation; footnote j=r GTGSISS(b);
Process points with PROC G3GRID. SMOOTH= specifies the smoothing parameter to use during spline interpolation.
proc g3grid data=reflib.nums out=smoothed; grid y*x=z / spline smooth=.05 axis1=-5 to 5 by .5 axis2=-5 to 5 by .5; run;
Generate a surface plot.
proc g3d data=smoothed; plot y*x=z; run; quit;
Procedure features:
GRID statement options:
NEAR
PARTIAL
Data set: REFLIB.NUMS (see Example 1 on page 1336)
Sample library member: GTGPART
This example specifies a partial spline interpolation method on the GRID statement, using eight nearest neighbors for computing the estimates of the first and second derivatives. The output data set, when used in PROC G3D, generates a smoother surface plot than the surface plot that results from the default interpolation shown in Example 1 on page 1336, but not as smooth as the surface plot that results from the spline interpolation shown in Example 2 on page 1339.
Assign the libref and set the graphics environment.
libname reflib SAS-data-library ; goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftext=swiss ftitle=swissb htitle=6 htext=3;
Define title and footnote.
title Surface Plot after Partial Interpolation; footnote j=r GTGPART;
Process points with PROC G3GRID. PARTIAL specifies that a spline be used to estimate the derivatives for the biquintic polynomial interpolation. NEAR= specifies the number of nearest neighbors to be used for computing the estimates of the first and second derivatives.
proc g3grid data=reflib.nums out=partial; grid y*x=z / partial near=8 axis1=-5 to 5 by .5 axis2=-5 to 5 by .5; run;
Generate the surface plot.
proc g3d data=partial; plot y*x=z; run; quit;
Procedure features:
GRID statement options:
AXIS1=
AXIS2=
SPLINE
Data set: REFLIB.NUMS (see Example 1 on page 1336)
Sample library member: GTGSPLIN
This example demonstrates the default and spline interpolation methods when used by the GCONTOUR procedure to generate contour plots from the resulting output data sets.
Assign the libref and set the graphics environment.
libname reflib SAS-data-library ; goptions reset=global gunit=pct border cback=white colors=(black blue green red) ftext=swiss ftitle=swissb htitle=6 htext=3;
Define title and footnote.
title Contour Plot after Default Interpolation; footnote j=r GTGSPLIN(a);
Define axis characteristics.
axis1 width=3;
Process points with PROC G3GRID.
proc g3grid data=reflib.nums out=numdef; grid y*x=z / axis1=-5 to 5 by .5 axis2=-5 to 5 by .5; run;
Generate the contour after default interpolation.
proc gcontour data=numdef; plot y*x=z / haxis=axis1 vaxis=axis1; run;
Define new title and footnote.
title Contour Plot after Spline Interpolation; footnote j=r GTGSPLIN(b);
Process points with PROC G3GRID. SPLINE specifies the bivariate spline method for the data set interpolation.
proc g3grid data=reflib.nums out=numspl; grid y*x=z / spline axis1=-5 to 5 by .5 axis2=-5 to 5 by .5; run;
Show the contour after spline interpolation.
proc gcontour data=numspl; plot y*x=z / haxis=axis1 vaxiss=axis1; run; quit;