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

Hi,

 

How can I calculate the probability of a logistic regression model given the values of independent variables not only by hand but also by SAS? Please show me some sample code.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try @Ksharp's code. Start by omitting data=test to score the original data (the crops dataset).

PG

View solution in original post

6 REPLIES 6
Reeza
Super User

This is known as scoring a model.

 

As of SAS 9.4 there's the CODE statement that will generate the code you need to score your data.

See several of the options with example code here:

http://blogs.sas.com/content/iml/2014/02/19/scoring-a-regression-model-in-sas.html

 

This thread has a fully worked example that's a manual process BEFORE the availability of the CODE statement.

https://communities.sas.com/t5/SAS-Statistical-Procedures/How-to-determine-logistic-regression-formu...

 

I'd use the CODE option now. 

PGStats
Opal | Level 21

Note that the CODE generation is not implemented for all models. I learned the hard way (not in the doc) that I can't get the code for scoring a model containing a constructed spline effect. I am using version 13.1 but I don't see any mention of the feature being added to more recent versions.

PG
Ksharp
Super User
There are about three way to score data: CODE , SCORE, STORE statements.
Check documentation example Example 72.16: Scoring Data Sets .

The simplest is SCORE

proc logistic data=Crops;
model Crop=x1-x4 / link=glogit;
score data=Test  out=Score1;
run;

chowfar
Calcite | Level 5
lets say I have the values for x1-x4, how can I find the logistic probability of Crop. What should be the code?
Reeza
Super User

@chowfar Have you looked at any of the indicated references? Which ones were unclear? 

PGStats
Opal | Level 21

Try @Ksharp's code. Start by omitting data=test to score the original data (the crops dataset).

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 2027 views
  • 4 likes
  • 4 in conversation