Sample 24862: Control the order and range of the X, Y and Z axes with PROC G3D
This sample program uses PROC G3D to control the range of the X, Y and Z axes.
There are several different ways this program could have been designed. In this example, the axis ranges are controlled with macro values that the user manually provides. If there are data values that are outside the macro value ranges, then the macro values will be ignored. If you wanted to force the macro values to override the input data ranges, you will need to write a DATA step that deletes the X, Y and/or Z data values that were outside the associated macro value ranges in order to control the axes ranges.
You can also make this program more dynamic by capturing the minimum
and maximum values for the X, Y and Z variables using PROC MEANS. Then create an
alogorithm that adds or subtracts a calculated value to the minimum and
maximum of each X, Y and Z data value range. Finally, add the new X, Y and Z
values to the two dummy observations (as shown in the sample code).
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample program uses PROC G3D to control the range of the X, Y and Z axes.
The graphics output in the Results tab was produced using SASĀ® 9.2. Submitting
the sample code with releases of SAS prior to SAS 9.2 might produce different results.
/* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;
%let x_min=-.05;
%let x_max=1.25;
%let x_ticks=3;
%let y_min=-.05;
%let y_max=1.25;
%let y_ticks=3;
%let z_min=-10.05;
%let z_max=10;
%let z_ticks=5;
data a;
do i=-10 to 10 by 1;
ZVAR=i;
XVAR=ranuni(0);
YVAR=ranuni(1);
output;
end;
run;
data b;
length colorval shapeval $ 8;
set a end=last;
colorval='CX7C95CA'; shapeval='prism';
output;
if last; /* Create two 'dummy' observations with the min and max x, y and z values */
xvar=&x_min;
yvar=&y_min;
zvar=&z_min;
colorval='white';
shapeval='point'; /* 'Hide' the 'dummy' points */
output;
xvar=&x_max;
yvar=&y_max;
zvar=&z_max;
colorval='white';
shapeval='point'; /* 'Hide' the 'dummy' points */
output;
run;
title1 "Control the order and range with PROC G3D";
proc g3d;
scatter yvar*xvar=zvar / size=2 color=colorval shape=shapeval
xticknum=&x_ticks yticknum=&y_ticks zticknum=&z_ticks;
run;
quit;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample program uses PROC G3D to control the range of the X, Y and Z axes.
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> G3D
|
Date Modified: | 2008-12-22 14:52:46 |
Date Created: | 2004-11-11 11:07:52 |
Operating System and Release Information
SAS System | SAS/GRAPH | All | n/a | n/a |