Sample 24862: Control the order and range of the X, Y and Z axes in PROC G3D
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 need to write a DATA step that deletes the X, Y and/or Z data values that were outside the associated macro value ranges inorder to control the axes ranges.
You could also make this program more dynamic by getting the minimum
and maximum 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. Then add the new X, Y and Z
values to the two 'dummy' observations, as shown in the sample code.
goptions reset=all border cback=white;
%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='blue'; 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;
proc g3d;
scatter yvar*xvar=zvar / size=2 color=colorval shape=shapeval
xticknum=&x_ticks yticknum=&y_ticks zticknum=&z_ticks;
title h=1.25 'Sample Data';
run;
quit;

This program is designed to control the range of the X, Y and Z axes of PROC G3D.
| 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 |