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;
Thanks,
Cara
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;
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;
Ahh. Thanks - this worked!
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.
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.
Ready to level-up your skills? Choose your own adventure.