SGPLOT Procedure

Example 5: Adding a Prediction Ellipse to a Scatter Plot

Features:

SCATTER statement

ELLIPSE statement

KEYLEGEND statement

Sample library member: SGPLELI
This example shows a scatter plot with a prediction ellipse.

Output

SGPLELI - Adding a Prediction Ellipse to a Scatter Plot

Program

proc sgplot data=sashelp.iris;
  title "Iris Petal Dimensions";
  scatter x=petallength y=petalwidth;
  ellipse x=petallength y=petalwidth;
  keylegend / location=inside position=bottomright;
run;
title;

Program Description

Set the title and create the scatter plot.
proc sgplot data=sashelp.iris;
  title "Iris Petal Dimensions";
  scatter x=petallength y=petalwidth;
Create the ellipse.
  ellipse x=petallength y=petalwidth;
Position the Legend. The LOCATION= option places the legend inside of the plot area. The POSITION= option places the legend at the bottom right.
  keylegend / location=inside position=bottomright;
run;
Cancel the title.
title;