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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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