06-02-2014 01:46 PM
I have a scatter plot upon which I must overlay three other items:
1. Centroid value of X and Y (one value with marker)
2. A circle +/- 2.5 units of the centroid
3. A circle of +/-5.0 units of the centroid
What is the most effective way of doing this?
06-02-2014 02:59 PM
Which procedure do you plan on using?
Depending on procedure and version of SAS the second 2 are probably easiest with an annotate data set as you specify a a coordinate and radius for a circle. Which would require about 3 lines of code. Look at the %Circle macro in the annotate facility.
06-02-2014 03:28 PM
Simplest I can think of:
x = 5; y=5;
proc sgplot data=junk;
scatter x=x y=y /markerattrs=(symbol=circlefilled) name='yes';
scatter x=x y=y /markerattrs=(symbol=circle size=25mm) name='no';
scatter x=x y=y /markerattrs=(symbol=circle size=50mm) name='no2';
keylegend 'yes' /title='Legend';
The size and units would likely change depending on the size of your final display and you may want to play with axis defintions to make it prettier.
06-02-2014 04:08 PM
If circles are not important, you can use XERRORUPPER/LOWER and YERRORUPPER/LOWER to show the +/-2.5 and +/-5.0 limits. You should need only two scatter overlays to show these limits, the first scatter can show the real point and the +/- 2.5 limits. The code will look something like this:
proc sgplot data=somedata nocycleattrs;
scatter x=x y=y / xerrorupper=xulimit50 xerrorlower=xllimit50 yerrorupper=yulimit50 yerrorlower=yllimit50 markerattrs=(size=0);
scatter x=x y=y / xerrorupper=xulimit25 xerrorlower=xllimit25 yerrorupper=yulimit25 yerrorlower=yllimit25;
06-02-2014 05:53 PM
If you're going to use the ODS Graphics systems to do this at SAS 9.2, the only way that comes to mind (warning: this is brute force) is to use ELLIPSEPARM statements in GTL. You would have to write a macro loop to generate an ELLIPSEPARM statement for each circle needed in the plot. Here is some pseudo-code for the idea:
define statgraph myscatter;
scatterplot x=x y=y;
%do %p=1 %to numberOfCircles;
ellipseparm semimajor=%unit semiminor=%unit slope=0 xorigin=%x yorigin=%y;
proc sgrender data=somedata template=myscatter; run;