turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- How to show regression equation and calculate pred...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-29-2016 08:46 PM - last edited on 03-29-2016 09:07 PM by Reeza

so,fo example i have this results (PROC REG). now i have to show regresson equaton (which is y=0.33096x+1028.57177) on my graph. Moreover, i need find "y" for different x?

Thank you.

**Goal: Displaying Regression Equations in Fit Plots and use this equation to find "y" for certain x**

Accepted Solutions

Solution

10-11-2017
11:34 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bigban777

03-30-2016 09:06 AM

You didn't say what version of SAS you are using, but here how to use PROC SGPLOT to display the slope and intercept of a regression line.

If you want to get REALLY fancy, you can use string concatenation to construct an "equation" and display the equation.

There are many ways to score a regression model. See examples and explanations in this article: Techniques for scoring a regression model in SAS

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bigban777

03-29-2016 09:05 PM

How are you making your graph? Where do you want to include equation?

Look at score and/or proc score to calculate predictions.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bigban777

03-29-2016 10:24 PM

If you are plotting using SGPLOT, use INSET statement to show the equation. If you want the predicted y values for your data x values, then use an OUTPUT statement in PROC REG. You can also create the SAS code for the calculation of predicted values in a separate data step with the CODE statement in PROC REG.

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bigban777

03-29-2016 11:30 PM

1) " calculate predicted value for new observation" Put your train table and test table together, then you will magically find SAS has already done it for you . 2) "show regression equation " Save these parameter and use proc sgplot get it . I remember proc gplot can directly get the fitted function no need save these parameter. But I can't recall that . data train; set sashelp.class(keep=weight height); run; data test; height=71;output; height=72;output; run; data have; set train test; run; proc reg data=have outest=est noprint; model weight=height; output out=want predicted=predicted; run; proc print data=want noobs;run; data _null_; set est; call symputx('func',cats('weight=',intercept,'+',height,'*height')); run; proc sgplot data=train aspect=1; reg x=height y=weight/ cli clm; inset "&func"/ position=topleft textattrs=graphdata1(size=12); run;

Solution

10-11-2017
11:34 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bigban777

03-30-2016 09:06 AM

You didn't say what version of SAS you are using, but here how to use PROC SGPLOT to display the slope and intercept of a regression line.

If you want to get REALLY fancy, you can use string concatenation to construct an "equation" and display the equation.

There are many ways to score a regression model. See examples and explanations in this article: Techniques for scoring a regression model in SAS