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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1660 views
  • 2 likes
  • 2 in conversation