- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I want to create a scatter plot showing correlation with a best fit line. When I use ellipse=0.2 0.3 in PROC CORR I find a scatter plot with circle best line. I want a straight best line like the picture I attached.
I want to create a scatter plot which shows r and P-value for correlation with a best fit line. Can you help me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Some of us (like me) never download attachments. Please show us the plot of interest by clicking on the "Insert Photos" icon and not via attaching a file.
Also, take a look at the ELLIPSE statement and the example here, if this is what you want, except no line, we can do this and add the line.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Create output data from Proc Corr.
Use a data step to use that information to create a series of points for the line
Combine that data with the raw data
Use SGPLOT and overlay a Scatter plot of the raw data with a Series plot of the line points created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Plot:
proc sgplot data=sashelp.class;
reg x=height y=weight ;
run;
Values - need to get from PROC CORR and add in using INSET
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
ods select none;
ods output parameterEstimates=pEst fitStatistics=fStats;
proc reg data=sashelp.class;
model weight = height;
output out=graphingData p=predicted;
run;
data _null_;
set fStats (obs=1);
call symputx('corr', put(sqrt(nValue2), 12.4));
run;
data _null_;
set pEst(obs=2);
call symputx('pvalue', put(probT, pvalue.));
run;
ods select all;
proc sgplot data=sashelp.class;
reg x=height y=weight ;
inset ("Correlation = " = "&corr."
"P-Value =" = "&pvalue.");
run;