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

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*/
1 ACCEPTED SOLUTION

Accepted Solutions
STAT_Kathleen
SAS Employee

The following SAS Usage Note:

  http://support.sas.com/kb/33307

demonstrates 4 ways to score new observations using a previously fitted model .

 

 

View solution in original post

7 REPLIES 7
Ksharp
Super User
you can use option
proc genmod ...... outest=est
to save estimate coefficient and score the test data lately .

@Rick_SAS wrote many blog about this topic .
Reeza
Super User

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

 

  1. Missing response trick (ie combining regression + predictive data set)
  2. PROC SCORE
  3. SCORE statement within PROC
  4. STORE Statement + PROC PLM
  5. CODE statement - generates data step code to generate your predictive values. If you want to understand the math behind your formula this is a good optin. 

 

Ronein
Meteorite | Level 14

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;
Reeza
Super User
There is no OUTEST option in PROC GENMOD. Please see the documentation.
https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statu...

Other methods to do this have been shown by several other people so you'll need to use a different option.
Ksharp
Super User
Opps. My bad. I reckon that proc genmod like proc reg .
PaigeMiller
Diamond | Level 26

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...

--
Paige Miller
STAT_Kathleen
SAS Employee

The following SAS Usage Note:

  http://support.sas.com/kb/33307

demonstrates 4 ways to score new observations using a previously fitted model .

 

 

sas-innovate-white.png

Register Today!

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.

Register now!

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
  • 7 replies
  • 1416 views
  • 17 likes
  • 5 in conversation