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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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