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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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