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

Hi SAS Community,

 

I am attempting to create a scatter plot of the correlation between two variables: agestartm and pcrCT. I've been googling and searching for a way to change the inset location on the plot, but haven't found any solutions. Does anyone have a way to do this? 

 

I've attached my code and graph for reference.

ods graphics on;
proc corr data=mydata nomiss
	plots=scatter(alpha=.05);
	var agestartm pcrct;
	run;
ods graphics off;
	

 ScatterPlot.png

 

Thanks,

Cara

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

When the automatically produced ODS graphics look like you want, they are a big time saver. When they don't look like you want and the procedure does not support the option to tweak the graph, it is often easiest to use PROC SGPLOT to make the changes that you need. This avoids having to mess with templates, which are powerful but have a learning curve associated with them. To put the inset in the position you want, use the INSET statement with the POSTITION= option:

 

/* original plot */
proc corr data=sashelp.cars nomiss plots=scatter(alpha=.05);
	var weight wheelbase;
run;

/* create same plot "by hand" */
title "Scatter Plot";
title2 "With 95% Prediction Ellipses";
proc sgplot data=sashelp.cars;
   scatter x=Weight y=Wheelbase;
   ellipse x=Weight y=Wheelbase;
   /* use INSET stmt to put the inset anywhere you want */
   inset ("Observations" = "428"
          "Correlation" = "0.7607"
          "p-Value" = "<.0001") / border position=SE;
run;

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

When the automatically produced ODS graphics look like you want, they are a big time saver. When they don't look like you want and the procedure does not support the option to tweak the graph, it is often easiest to use PROC SGPLOT to make the changes that you need. This avoids having to mess with templates, which are powerful but have a learning curve associated with them. To put the inset in the position you want, use the INSET statement with the POSTITION= option:

 

/* original plot */
proc corr data=sashelp.cars nomiss plots=scatter(alpha=.05);
	var weight wheelbase;
run;

/* create same plot "by hand" */
title "Scatter Plot";
title2 "With 95% Prediction Ellipses";
proc sgplot data=sashelp.cars;
   scatter x=Weight y=Wheelbase;
   ellipse x=Weight y=Wheelbase;
   /* use INSET stmt to put the inset anywhere you want */
   inset ("Observations" = "428"
          "Correlation" = "0.7607"
          "p-Value" = "<.0001") / border position=SE;
run;
cbt2119
Obsidian | Level 7

Ahh. Thanks - this worked!

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2310 views
  • 2 likes
  • 2 in conversation