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

I have regression model of the form Y = X + X^2. I need to plot the observed and the predicted values of Y against X on the same plot. I am thinking of using the overlay option in PROC REG.

OUTPUT P gives the predicted values as far as I understood. But how do I save it in a variable, say Yhat?

How do I get the predicted values from the regression summary to write the statement plot Y*X Yhat*X/overlay ;

 

 

Thank You.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

In PROC REG, in the PLOT statement, you get the predicted values via

 

plot y*x predicted.*x/overlay;

https://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=statug&docsetTarget=statug_re...

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

In PROC REG, in the PLOT statement, you get the predicted values via

 

plot y*x predicted.*x/overlay;

https://documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=statug&docsetTarget=statug_re...

--
Paige Miller
PGStats
Opal | Level 21

You can get more control over the graph appearance with proc sgplot. For example:

 

proc sgplot data=sashelp.heart noautolegend;
reg x=ageAtStart y=cholesterol / degree=2 cli
    markerattrs=(symbol=circlefilled size=4) transparency=0.2;
run;

SGPlot3.png

PG

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1094 views
  • 0 likes
  • 3 in conversation