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

Hello,

I understand fitplot is not an option with Proc Reg when you have a multi-variable model.  But what do I do if I want to plot the fitted values vs the actual values?  Is there any work around that provides a similar look/feel?  I used the output function to create a new dataset with the predicted values and tried plotting those (see code below), but when I tried to plot the fitted (yhat) values as a series the line was erratic (see attached).

ods graphics on;

proc sgplot data = fitted_model;

scatter X =x1 Y=Y /markerattrs =(color = blue);

series X =x1 Y=yhat /lineattrs =(color = red);

run;

quit;Screen Shot 2014-01-18 at 10.30.13 PM.png

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

If you want to show the linear relationship between x1 and Y then you should sort your data BEFORE doing the regression :

proc sort data=myData; by my01variable x1; run;

proc reg data=myData ...;

....

run;

 

ods graphics on;

proc sgplot data = fitted_model;

scatter X =x1 Y=Y / markerattrs =(color = blue);

series X =x1 Y=yhat / group=my01variable lineattrs =(color = red);

run;

where my01variable is the dummy variable that generates the two lines in the x1-Y relationship.

PG

PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

If you want actual by fitted (which is not a FITPLOT but a OBSERVEDBYPREDICTED plot), seems like you should be plotting

scatter X =Yhat Y=Y / markerattrs =(color = blue);

and no series.

PG

PG
PGStats
Opal | Level 21

If you want to show the linear relationship between x1 and Y then you should sort your data BEFORE doing the regression :

proc sort data=myData; by my01variable x1; run;

proc reg data=myData ...;

....

run;

 

ods graphics on;

proc sgplot data = fitted_model;

scatter X =x1 Y=Y / markerattrs =(color = blue);

series X =x1 Y=yhat / group=my01variable lineattrs =(color = red);

run;

where my01variable is the dummy variable that generates the two lines in the x1-Y relationship.

PG

PG
BenPorter
Calcite | Level 5

THANK YOU!!!  Didn't realize I had to sort it...was driving me NUTS!!!!

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
  • 3 replies
  • 1603 views
  • 0 likes
  • 2 in conversation