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

Hello, I am using SAS Studio Release 3.81.

I'm learning basic SAS procedures for the first time. One of the methods is Two-Way ANOVA and now checking the model.

 

For running the Two-Way ANOVA I use this code:

proc anova data=athlete;
	class lifestyle sex;
	model systolic diastolic = lifestyle sex lifestyle*sex;
	means lifestyle sex / duncan lines;
run;

This particular model has two different responses, and this code gives me the ANOVA for each of the models.

 

For model diagnostics, the book I'm using recommends this procedure:

proc glm data=athlete;
	class lifestyle sex;
	model systolic = lifestyle sex lifestyle*sex;
	output out=systolic p=yhat student=resid;
title1 'Two-Way ANOVAs for Lifestyle BP Study';
run;

proc gplot data=systolic;
	plot resid*yhat / vref = 0;
	title2 'Resid vs Y-hat';
	
	plot resid*lifestyle / vref = 0;
	title2 'Resid vs Lifestyle';
	
	plot resid*sex / vref = 0;
	title2 'Resid vs Sex';
run;

proc univariate data = systolic normal;
	var resid;
	probplot resid / normal (mu = est sigma = est) square;
	title2 'Normal Test of Residuals';
run;

I would then have to run this again for the diastolic response. The issue I'm having is that I can only run the diagnostics for one response at a time. The proc glm step only outputs one set of predicted yhat and residuals for the first predictor listed. Is there a way to output the predicted values and residuals for each response variable in the proc glm?

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You want this ?

proc glm data=sashelp.heart;
	class status sex;
	model systolic diastolic = status|sex;
	output out=want p=yhat yhat2 student=resid resid2;
quit;

View solution in original post

2 REPLIES 2
Ksharp
Super User

You want this ?

proc glm data=sashelp.heart;
	class status sex;
	model systolic diastolic = status|sex;
	output out=want p=yhat yhat2 student=resid resid2;
quit;
kevinbu
Calcite | Level 5

Yes, thank you that works!

 

In case anyone after me is curious, I found an example of this in the documentation.

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.3/statug/statug_glm_details65.htm

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 1226 views
  • 2 likes
  • 2 in conversation