BookmarkSubscribeRSS Feed
mdphdUTMB
Calcite | Level 5

Can someone tell me how to modify a correlation plot to have the same scale for the x and y axis that begins at the origin?

 

When I use my current code below, my graph "zooms in", but I want to display it differently.

ods graphics on;
PROC CORR DATA=TBI1 PLOTS=SCATTER(NVAR=all);
VAR D16MWT D26MWT;
RUN;
ods graphics off;

 

graph:

mdphdUTMB_0-1648516526880.png

Thank you in advance!

2 REPLIES 2
Rick_SAS
SAS Super FREQ

It sounds like you should use PROC SGPLOT if you want complete control over axes ranges. Compare the following two plots:

 

proc corr data=sashelp.class plots=scatter;
var weight height;
run;

title "Scatter Plot";
title2 "With 95% Prediction Ellipse";
proc sgplot data=sashelp.class;
   scatter x=weight y=height;
   ellipse  x=weight y=height;
   xaxis min=0;  /* do you also want MAX=500 ? */
   yaxis min=0;  /* do you also want MAX=500 ? */
run;

I'm not sure if " the same scale for the x and y axis" means that you also want the maximum value for each axis to be the same. If so, use the MAX= option on the XAXIS and YAXIS statements, as shown in the comments.

Ksharp
Super User
Rick have already given you answer. My code is the same as him .

proc sgplot data=sashelp.class aspect=1 noautolegend;
scatter x=weight y=height;
ellipse x=weight y=height/ alpha=0.05;
inset 'obs =19' 'Corr =0.877' 'Pvalue=<.0001';
xaxis min=0;
yaxis min=0;
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
  • 2 replies
  • 739 views
  • 0 likes
  • 3 in conversation