Initial data is created directly in the script via a DATA STEP block and the 'datalines' statement. All subsequent data is derived from this internal source.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates the 'raw_data' table containing X, Y, Z coordinates. The data is embedded directly in the code using the 'datalines' statement.
Explanation : The G3GRID procedure is used for interpolation. It takes the raw data ('raw_data') and generates a new 'smoothed' table with a finer grid of points. The 'spline' option with 'smooth=.05' applies a cubic spline smoothing to obtain a regular surface.
Copied!
proc g3grid data=raw_data out=smoothed;
grid y*x=z / spline smooth=.05
axis1=-1 to 1 by .1
axis2=-1 to 1 by .1;
run;
1
PROC G3GRIDDATA=raw_data out=smoothed;
2
grid y*x=z / spline smooth=.05
3
axis1=-1 to 1BY .1
4
axis2=-1 to 1BY .1;
5
RUN;
3 Code Block
DATA STEP Data
Explanation : This DATA STEP modifies the 'smoothed' table to simulate two distinct surfaces. It creates two new variables 'z1' and 'z2' by offsetting the original 'z' value by -8 and +8 respectively.
Copied!
data smoothed; set smoothed;
label z1='Z' z2='Z';
z1=z-8;
z2=z+8;
run;
1
DATA smoothed; SET smoothed;
2
label z1='Z' z2='Z';
3
z1=z-8;
4
z2=z+8;
5
RUN;
4 Code Block
ODS / GOPTIONS
Explanation : This block configures the output environment. 'goptions' sets graph parameters (device, size). ODS (Output Delivery System) is configured to close standard listing output and redirect output to an HTML file. The 'nodisplay' option prevents immediate display of graphs.
Explanation : The G3D procedure generates the first 3D graph based on the 'z1' variable. 'name="plot1"' saves the graph to the work catalog for later use. The text is set to white to prepare for superposition and avoid visual artifacts.
title ls=1.5"Overlay Multiple G3D Surfaces, using Greplay";
4
PROC G3DDATA=smoothed;
5
plot y*x=z1 /
6
grid zmin=0 zmax=30 xticknum=4 tilt=80
7
ctop=purple cbottom=cx00ff00 des='' name="plot1";
8
RUN;
6 Code Block
PROC G3D
Explanation : The G3D procedure generates the second 3D graph based on the 'z2' variable, using the same axis and angle parameters as the first to ensure perfect alignment. The graph is saved as 'plot2' and the text is set to black.
Explanation : The 'goptions display' option is re-enabled. The GREPLAY procedure overlays the two graphs ('plot1' and 'plot2') in a single area defined by the 'WHOLE' template. The 'treplay' statement executes this superposition, creating the final composite graph.
Explanation : This block finalizes the process by closing the HTML output file and reactivating the default ODS LISTING destination.
Copied!
ODS HTML CLOSE;
ODS LISTING;
1
ODS HTML CLOSE;
2
ODS LISTING;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.