Hello
Please find example to data set that check if the football player scored goals in last game.
The dependent variable is GoalInd (binary) and there are 3 independent variables X1,X2,X3.
I used proc genmod to build regression model.
I want to use the regression equation that was created in order to calculate probability for new cases (data set new).
As I understand from my previous post there are 2 recommended way to do it:
Way1-Create a data set that store the regression equation and then use it to calculate predicted values for new cases
Way2- Use store statement in proc reg and then use Proc PLM to calculate predicted values for new cases
May you show please the code for way 1 and also the code for way 2?
thank you so much
Data Rawtbl;
input ID GoalInd X1 X2 $ X3 $;
cards;
1 0 20 W N
2 0 30 W N
3 1 20 B N
4 1 20 B N
5 0 30 B Y
6 0 20 B Y
7 1 20 W N
8 0 30 B Y
9 1 20 W N
10 1 30 B N
;
run;
/*Step1-Build regression equatiuon*/
proc genmod data=Rawtbl namelen=60 descending;
class X1 X2 ;
model GoalInd=X1 X2 /dist=binomial link=logit type3 wald;
output out=Build_NewModel1
p=P_BAD xbeta=logit;
run;
/*Step1-Test the model on a new data set*/
Data new;
input ID GoalInd X1 X2 $ X3 $;
cards;
11 0 30 B Y
12 0 20 W N
13 1 30 B N
14 1 20 B Y
15 0 30 B Y
;
run;
/*Way1 to save the regression equation and use it */
/*How can I save the Regression equation in a data set?*/
/*How can I use this data set to calculate predicted outcome for the new data set*/
/*Way2 to save the regression equation and use it */
/*How can I use store statement in proc genmod in order to save the resression equation?*/
/*How can I use these regression equation (that was stored in store statement in proc genmod) to
calculate predicted outcome for the new data set*/
The following SAS Usage Note:
http://support.sas.com/kb/33307
demonstrates 4 ways to score new observations using a previously fitted model .
One of Rick's blog posts that covers your question is here and outlines five different ways and some of the differences between them.
https://blogs.sas.com/content/iml/2014/02/19/scoring-a-regression-model-in-sas.html
Thank you, however when I add outest=est then I get an error
proc genmod data=Rawtbl outest=est namelen=60 descending ;
class X1 X2 ;
model GoalInd=X1 X2 /dist=binomial link=logit type3 wald;
output out=Build_NewModel1
p=P_BAD xbeta=logit;
run;
You can use the STORE command in PROC GENMOD or PROC GLM and then PROC PLM to get predicted values. Example: https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.3&docsetId=statug&docsetTarget=statu...
The following SAS Usage Note:
http://support.sas.com/kb/33307
demonstrates 4 ways to score new observations using a previously fitted model .
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.