BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi all,

I'm running a PROC GLM with two groups of regressors - say vectors X1 and X2 (some of which are class variables). The standard OUTPUT statement allows me to compute the predicted values of the Y on X1 and X2.

However, I need to predict Y only with the information in X1, i.e. instead of b1*X1+b2*X2, just b1*X1.

As these vectors have thousands of variables, I can't do it manually. Do you know of a way to do it in SAS?

Thanks a lot!
Stefano
3 REPLIES 3
deleted_user
Not applicable
It seems that there's no option to output the design matrix X.
According to the last paragraph of http://support.sas.com/onlinedoc/913/getDoc/en/statug.hlp/glm_sect29.htm, the design matrix is not actually constructed.
Basically you got to generate the design matrix for factors in X1 by yourself using the rules on that web page before multiply it with the estimate of b1.
deleted_user
Not applicable
Thanks a lot, I will do it manually then.
deleted_user
Not applicable
You don't have to, because PROC GLMMOD will generate the design matrix for you. For example,
/*
data plants;
input Type $ @;
do Block = 1 to 3;
input StemLength @;
output;
end;
datalines;
Clarion 32.7 32.3 31.5
Clinton 32.1 29.7 29.1
Knox 35.7 35.9 33.1
O'Neill 36.0 34.2 31.2
Compost 31.8 28.0 29.2
Wabash 38.2 37.8 31.9
Webster 32.5 31.1 29.7
;
ods output designpoints=X(drop=obsnumber stemlength);
proc glmmod;
class Block Type;
model StemLength = Block Type;
run;
ods output parameterestimates=b(keep=estimate) predictedvalues=yhat;
proc glm data=plants;
class Block Type;
model StemLength = Block Type/p solution;
run;
proc iml;
use x;
read all var _num_ into X;
use b;
read all var {estimate} into b;
yhat = x*b;
b1 = b;
b1[5:11]=0;
yhat1 = x*b1;
print b b1;
print yhat yhat1;
quit;
*/
where b are the estimates of intercept, block, and type; yhat=X*b are the predicted values using both block and type; b1 are the estimates of intercept and block only; yhat1 = X*b1 are the predicated values using block only.
reference: http://support.sas.com/kb/23/217.html

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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