Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
Jackie418
Calcite | Level 5
How can I add the y=x line to my scatter plots?
Thanks
6 REPLIES 6
RickM
Fluorite | Level 6
Is this for proc gplot? I think the simplest way is to use the overlay option and plot one variable against itself.

proc gplot data=dataset;
plot y*x x*x/overlay;
run;

You could also create another dummy variable that spans the x/y axis in case there isn't enough variability in x or y.

Using an annotated dataset would also work.
Jackie418
Calcite | Level 5
Thanks. I just meant is there a way to plot a reference line with 0 intercept and slope = 1.
Jackie418
Calcite | Level 5
I am trying to make agreement plots without using the Ttest procedure in GPLOT or SGPLOT.
RickM
Fluorite | Level 6
Right, plotting any variable against itself is a line with an intercept at 0 and slope of 1 (x=1*x+0). SAS has options to add vertical or horizontal reference lines (x=5 or y=10) but not for x=y. That it why you would need to either plot another line (x*x or y*y) or use the annotation facility to draw a line on top of the graph.
Jackie418
Calcite | Level 5
Doh! 🙂 Thank you very much!
MikeZdeb
Rhodochrosite | Level 12
hi ... just to add onto the x*x suggestion already made ...

* some fake data;
data x;
do x = 1 to 10;
y = 6 + ceil(10*ranuni(999));
output;
end;
run;

goptions reset=all;

symbol1 v=dot c=blue;
symbol2 i=join c=blue ;

proc gplot data=x;
plot (y x)*x / overlay;
run;
quit;

also, using annotate is actually a bit harder in that the above method does not require you to have any knowledge as to how SAS/Graph will choose the ranges of the x and y axes

if you use annotate, then only safe way to add the line is to control the axis ranges with AXIS statements that specify ORDER and then use that axis range info to specify end points of a line drawn with annotate

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 9876 views
  • 0 likes
  • 3 in conversation