Search code examples
saslogistic-regression

SAS: Unable to run logistic regression


I trying to run logistic regression model in SAS for last few hours. But no luck. Is there any syntactic error? Here is the code:

options pageno=1 nodate; run;

data SEATBELT;
   input Belt $ Ejected $ Fatal $ Nonfatal $ Total;
   datalines;
Yes Yes 1105   14   1119
Yes No  411111 483  411594
No  Yes 4624   497  5121
No  No  157342 1008 158350
;

proc logistic data=SEATBELT;
    class Belt Ejected Fatal Nonfatal Total;
    model Fatal/Total= Belt Ejected / selection = b sls=0.05;
run;

And this is the error that I am getting.

 66         
 67         proc logistic data=SEATBELT;
 68         class Belt Ejected Fatal Nonfatal Total;
 69         model Fatal/Total= Belt Ejected / selection = b sls=0.05;
 70         run;

 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: The PROCEDURE LOGISTIC printed page 1.
 NOTE: PROCEDURE LOGISTIC used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds

Any help will be highly appreciated.

Thanks


Solution

  • The PROC is expecting numeric variables, you've read in portions of your data as a character. Remove the $ after FATAL and NONFATAL so they are read in as numeric.

    CLASS statement is for categorical data, so remove the variables from here, except EJECTED.

    I would also recommend adding in the PARAM=Ref option so that it uses referential coding.

    data SEATBELT;
       input Belt $ Ejected $ Fatal  Nonfatal Total;
       datalines;
    Yes Yes 1105   14   1119
    Yes No  411111 483  411594
    No  Yes 4624   497  5121
    No  No  157342 1008 158350
    ;
    
    proc logistic data=SEATBELT;
        class Belt Ejected/Param=REF;
        model Fatal/Total= Belt Ejected / selection = b sls=0.05;
    run;