G3D Procedure
Example 6: Generating a Scatter Plot with Modified Shapes and a Grid
Features: |
SCATTER statement
- SCATTER statement options:
- COLOR=
- GRID
- NONEEDLE
- SHAPE=
- SIZE=
|
Other features: |
DATA Step
|
This scatter plot modifies
the results of measuring the petal length, petal width, and sepal
length for the flowers of three species of irises. It uses a DATA
step to add a color variable and a shape variable to the data set,
shapes to distinguish iris species, and colors to distinguish iris
species. It also removes needles from data points and adds a grid.
Program
goptions reset=all border;
title1 "Iris Species Classification";
title2 "Physical Measurement";
footnote1 j=r f="Albany AMT/it" "Source: Fisher (1936) Iris Data";
data iris;
set sashelp.iris;
length color shape $8.;
if species="Setosa" then do; shape="club"; color="blue"; end;
if species="Versicolor" then do; shape="diamond"; color="red"; end;
if species="Virginica" then do; shape="spade"; color="green"; end;
run;
proc g3d data=iris;
scatter PetalLength*PetalWidth=SepalLength/
color=color
shape=shape
size=1.5
noneedle
grid;
run;
quit;
Program Description
Set the graphics environment.
goptions reset=all border;
Define the titles and footnote.
title1 "Iris Species Classification";
title2 "Physical Measurement";
footnote1 j=r f="Albany AMT/it" "Source: Fisher (1936) Iris Data";
Add variables to original data set.
data iris;
set sashelp.iris;
length color shape $8.;
if species="Setosa" then do; shape="club"; color="blue"; end;
if species="Versicolor" then do; shape="diamond"; color="red"; end;
if species="Virginica" then do; shape="spade"; color="green"; end;
run;
Generate the surface plot.
proc g3d data=iris;
scatter PetalLength*PetalWidth=SepalLength/
color=color
shape=shape
size=1.5
noneedle
grid;
run;
quit;
Copyright © SAS Institute Inc. All rights reserved.