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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 10385 views
  • 0 likes
  • 3 in conversation