I am running proc logistic. There are one independent variable and one dependent variable. The independent variable is a numeric variable. I used format to make this variable have only 2 values, 'detect' and 'not detect'. The dependent variable only has two category, 0 and 1.
I did not add the class statement for the independent variable in proc logistic procedure and SAS still gave me result. This result is different from that of adding the class statement. I want to know how SAS got the result without the class statement.
My guess....would be easy to test, but I'll assume you can do that
Assuming the independent variable (IV) was a number, SAS treated it as a continuous variable. If the values for the IV were not binary then the results would not be consistent between the two procedures.
Proc logistic doesn't require the response variable to be declared in a class statement. Check in the listing which level of your response variable was modelled (i.e. used as an event) in both cases. You can change which level is used as an event with EVENT= or DESCENDING options in the MODEL statement.
PG
Programs with and without class statement use the same response variable and reference level. So, the different result is not related to the coding of response variable. I am still waiting for the answer.
Could you post the two pieces of code that give different estimates, as well as the format used?
My guess....would be easy to test, but I'll assume you can do that
Assuming the independent variable (IV) was a number, SAS treated it as a continuous variable. If the values for the IV were not binary then the results would not be consistent between the two procedures.
Thank you PGStats and Reeza. I tested 10 situations.
I found out that even if the continuous independent variable is formatted to two categories, proc reg without class statement still uses the original continuous values.
Reeza is right.
Here's a link to some other gotcha's on using Logistic Regression in SAS:
Logistic Regression – Quick Tips | Statistics and other stuff from a geek
Thank you for your article. My concern is more related to how SAS treats the data with format.
After testing, I found out that continuous independent variable with two values 0 and 1 can produce the correct result. It is not necessary to use class statement to declare this variable is class variable.
But if the continuous variable has more than 2 values and format statement is used to classify the values of variable, class statement must be used.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.