BookmarkSubscribeRSS Feed
DShah
Fluorite | Level 6

Hi

I have a dataset in SAS. I want to calculate slope and r2 for the data in the last two columns respectively. can you please help me in writing a procedure.

 

Thank you in advance.

3 REPLIES 3
art297
Opal | Level 21

If you only need to find the linear relationship you can obtain both the R2 and slope using PROC REG (see: https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_reg_sect003... )

e.g.:

 

   proc reg;
      model sum_CiS = Q;
   run;

 HTH,

Art, CEO, AnalystFinder.com

 

DShah
Fluorite | Level 6

Hi Art

Thank you for your reply. Is there a way to add the Slope and R2 values in the table?

 

Thank you!

art297
Opal | Level 21

Not sure what you're asking. Both are included in the output.

 

If you want them output to files, simply capture the ODS tables that contain them. e.g.:

 

ods output ParameterEstimates=estimates;
ods output FitStatistics=stats;
/* ods trace on; */
proc reg data=have;;
  model sum_CiS = Q;
run;
/* ods trace off; */

I commented out the ods trace on and off statements as they are only used to find out what ods output tables are available.

 

Art, CEO, AnalystFinder.com

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1529 views
  • 1 like
  • 2 in conversation