BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

I work on an analysis of agreement between two independent measurements from the same subjects (errors-variables-model, Demming regression). I want show the deviations from the identity line (Y1=Y2) as needles perpendicular to the 45 degree line. I cannot use the standard error bars option in SGPLOT.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

If (x, y) is one of your data points, you can use calculus to show that the perpendicular distance to the identity line is the point

( (x+y)/2, (x+y)/2).  So just write a DATA step and use the VECTR statement:

 

data Have;
input x y;
datalines;
1 2
3 5
2 3
2 1
4 5
5 3
3 4
4 4
4 .
;

data Want;
set Have;
x1 = (x + y)/2;
run;

proc sgplot data=Want aspectratio=1;
scatter x=x y=y;
vector x=x y=y / xorigin=x1 yorigin=x1 noarrowheads;
lineparm x=0 y=0 slope=1;
run;

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Since you didn't really tell us how you did the Deming regression, I will have to assume that you have the original data point, and the orthogonal projection onto the regression line. 

 

If you have these, then you can use the SG annotation feature that works with PROC SGPLOT, specifically the LINE function or the %SGLINE macro. A brief example is here: https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n0eben23mwnl3dn1cm95zbks0eea.htm&doc...

--
Paige Miller
carstenenevoldsen
Calcite | Level 5
Hi PaigeMiller,
Thanks for prompt reply.
I used Wicklin's IML code:

https://blogs.sas.com/content/iml/2019/01/07/deming-regression-sas.html,

PaigeMiller
Diamond | Level 26

Okay, but ... do you have the values of the perpendicular projections onto the line?

--
Paige Miller
Rick_SAS
SAS Super FREQ

If (x, y) is one of your data points, you can use calculus to show that the perpendicular distance to the identity line is the point

( (x+y)/2, (x+y)/2).  So just write a DATA step and use the VECTR statement:

 

data Have;
input x y;
datalines;
1 2
3 5
2 3
2 1
4 5
5 3
3 4
4 4
4 .
;

data Want;
set Have;
x1 = (x + y)/2;
run;

proc sgplot data=Want aspectratio=1;
scatter x=x y=y;
vector x=x y=y / xorigin=x1 yorigin=x1 noarrowheads;
lineparm x=0 y=0 slope=1;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 4 replies
  • 1215 views
  • 2 likes
  • 3 in conversation