Click here to see the SAS code.
Click here to see the example.

---------------------------------------------------------------

SAS/Graph version of chart on p. 1040 of Science magazine, 17nov2006
(using estimated values)

This graph looks kinda simple, but I had to use several "tricks" to
get the SAS/Graph gplot to look this way...

The gplot procedure prints the axes and tickmarks/values on the 
outside of the graph, not the inside, therefore I had to suppress
the values and tickmarks on the outside edges of the graph (using
value=none, major=none, and minor=none in the axis statements)
and use annotate to 'fake' the axis tickmarks and values along
the zero-line inside the graph.  The tickmarks are created using
annotate move/draw, and the numbers are annotated text labels.

To get the R-squared value printed inside the graph, I first used
"proc reg" to calculate the R-squared, and I saved the calculated
statistcs in a sas data set called 'outstats', then I used a 
data step to convert the value of the _RSQ_ variable (R-square
value) into a macro variable called 'rsq', which I could then 
use later as annotated text.  Note that proc reg could do it's
own plot, with R-Square and other statistics printed around the
graph, but I was striving to produce the *exact* same graph as
was in the "Science" magazine, therefore I am not using the 
built-in "proc reg" graphs.

I did add one slight "enhancement" over the original graph.
I added the very light graph border aound the entire graph,
so that you have a reference point, and can more eaily see
if the regression line heads towards the 'borner' of the graph,
or whether it's slightly askew.  You can easily get rid of these
graph borders by specifying "style=0" in the axis statements,
and "noframe" as a gplot option - then the graph will be just
like the one in the magazine.


Back to Samples Index