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

Using SAS 9.4 

 

Is there a way to take the r-squared from 

proc reg data= pt.eligible;
model impingment_point = ptp_translation /selection=rsquare;
run;

 

and add it to the graph I have using proc sgplot?

 

proc sgplot data = pt.eligible;
scatter x=ptp_translation y=impingment_point;
yaxis min=0 max=140 label = 'Distance to Impingement of 12 mm Stem Against Endosteal Surface';
xaxis min=0 max=40 label = 'Percentage Translation Between Sagittal Anatomic Axis and Joint Line Center';
title 'Proximal Tibial Translation and Distance to Impingement of a 12 mm Tibial Stem';
run;

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Here is an example using proc reg:

 

proc reg data=sashelp.cars plots=none;
where cylinders=4;
model horsepower = engineSize / rsquare;
output out=preds predicted=p_horsePower;
/* Use ods to output the r-square value into a dataset */
ods output fitStatistics=fs;
run;
quit;

/* Transfer the r-square value to a macro variable named RSQ */
data _null_;
set fs;
where label2="Adj R-Sq";
call symputx("RSQ", put(nvalue2, percentn7.1));
run;

proc sort data=preds; by engineSize; run;

proc sgplot data=preds noautolegend;
title "Horse Power for 4-cylinder engines";
scatter y=horsePower x=engineSize;
series y=p_horsePower x=engineSize;
inset ("Adj. R-Square:" = "&RSQ") / position=bottomright;
run;

image.png

PG

View solution in original post

2 REPLIES 2
ballardw
Super User

How do you want it to appear?

Since you are not using an output dataset from Proc Reg you might try adding a footnote or title with the text and value.

Or create an annotate data set with the value and appearance options you want.

PGStats
Opal | Level 21

Here is an example using proc reg:

 

proc reg data=sashelp.cars plots=none;
where cylinders=4;
model horsepower = engineSize / rsquare;
output out=preds predicted=p_horsePower;
/* Use ods to output the r-square value into a dataset */
ods output fitStatistics=fs;
run;
quit;

/* Transfer the r-square value to a macro variable named RSQ */
data _null_;
set fs;
where label2="Adj R-Sq";
call symputx("RSQ", put(nvalue2, percentn7.1));
run;

proc sort data=preds; by engineSize; run;

proc sgplot data=preds noautolegend;
title "Horse Power for 4-cylinder engines";
scatter y=horsePower x=engineSize;
series y=p_horsePower x=engineSize;
inset ("Adj. R-Square:" = "&RSQ") / position=bottomright;
run;

image.png

PG
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
  • 3198 views
  • 0 likes
  • 3 in conversation