tags:

views:

223

answers:

2

Support.sas.com provides this syntax for creating a prediction ellipse. The output dataset includes only the correlation results for the dataset. Is there any way to get information for the individual cases, such as labeling them in the graph or having the output include values for the individual cases?

I've tried adding the ID option to this code but was unsuccessful.

Scatter Plot with Prediction Ellipses

ods graphics on;

proc corr data=fish1

plots=scatter(alpha=.20 .30);

var Height Width;

run;

ods graphics off;

+3  A: 

If the data doesn't have to be printed on the graph itself, you can get observation level data shown as a mouse-over tip by using the imagemap=on ods option. This only applies to the html destination, though. By default, your Height and Weight and observation number values will be shown in the tip. The ID statment just lets you add more.

ods graphics on /imagemap=on;
ods html;
proc corr data=fish1
  plots=scatter(alpha=.20 .30);
  var Height Width;
run;
ods html close;
ods graphics off;


Update: Here's an easy way to get some data values printed on the plot. If you change datalabel=weight to datalabel=height it will print the height values for each observation instead. This uses the sgplot proc instead of the plots=scatter statement inside proc corr. Because of this the number of observations and the correlation are not printed on the plot but I'm sure you could find a way to add it if you needed.

ods graphics on /imagemap=on;
ods html;
proc sgplot data=Fish1;
  scatter x=Height y=Width /datalabel=weight;
  ellipse x=Height y=Width / alpha=.2;
  ellipse x=Height y=Width / alpha=.3;
  keylegend  / location=outside position=bottom;
run;
ods html close;
ods graphics off;
cmjohns
Great. This got me to at least know which cases are in or out. I still wish there was a way to output a variable indicating which cases fall in or out of the ellipse. I assume that because this is a plotting function, there is no way to calculate a new variable.
kgb
A: 

Not exactly the answer you are looking for but Warren Kufeld wrote a scatter plot macro that does this type of labeling for you. Check it out, possibly incorporate the logic in a subsequent step in your program to produce the plot with labels. http://support.sas.com/techsup/technote/ts722k.pdf

AFHood