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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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