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

Could anyone please forward me code for generating a table with AIC and AICc values in Proc logistic in SAS 9.2?

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

The AICC is produced in response to the request :

score out=drop fitstat;

in version 9.3...

I just checked the FITSTAT documentation in version 9.2 :

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_logistic_sec...

and only the four statistics that you got are produced. Smiley Sad

If you are using the AIC to compare models built on the same number of observations then it is very unlikely that you would get a different model ordering with AIC and AICC.

Best of luck.

PG

PG

View solution in original post

11 REPLIES 11
PGStats
Opal | Level 21

You can get AIC into dataset myAIC by adding the statement

ods output FitStatistics=myAIC(where=(criterion="AIC"));

to your proc logistic.

PG

PG
Swainsons
Fluorite | Level 6

PG,

Thanks for your response!  Could you please show me in the code below where to place the statement: ods output FitStatistics=myAIC(where=(criterion="AIC"));

Do I need to create "myAIC"?

options formdlim = '-';

PROC IMPORT OUT= WORK.BHCO

            DATAFILE= "C:\Users\nacharti\Desktop\PhD\Nest survival analysis\Logistic regression BHCO\Data\bhco5.jmp"

            DBMS=JMP REPLACE;

RUN;

Proc logistic data=BHCO desc; 

Class ; 

model Parisitized = CaneStemAvg; 

run;

Proc logistic data=BHCO desc; 

Class ; 

model Parisitized = CanCovAvg; 

run;

Proc logistic data=BHCO desc; 

Class ; 

model Parisitized = ForbAvg; 

run;

Proc logistic data=BHCO desc; 

Class ; 

model Parisitized = TreeLg CanCovAvg; 

run;

Proc logistic data=BHCO desc; 

Class ; 

model Parisitized = DenVerCV DenHorCV; 

run;

PGStats
Opal | Level 21

options formdlim = '-';

PROC IMPORT OUT= WORK.BHCO

DATAFILE= "C:\Users\nacharti\Desktop\PhD\Nest survival analysis\Logistic regression BHCO\Data\bhco5.jmp"

DBMS=JMP REPLACE;

RUN;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = CaneStemAvg;

ods output FitStatistics=AIC_CaneStemAvg(where=(criterion="AIC"));

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = CanCovAvg;

ods output FitStatistics=AIC_CanCovAvg(where=(criterion="AIC"));

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = ForbAvg;

ods output FitStatistics=AIC_ForbAvg(where=(criterion="AIC"));

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = TreeLg CanCovAvg;

ods output FitStatistics=AIC_TreeLgCanCovAvg(where=(criterion="AIC"));

run;

Proc logistic data=BHCO desc;

Class ;

model Parisitized = DenVerCV DenHorCV;

ods output FitStatistics=AIC_DenVerCVDenHorCV(where=(criterion="AIC"));

run;

data allAIC;

set AIC_: INDSNAME=modelVars;

run;

proc print; run;

PG

PG
PGStats
Opal | Level 21

Wait! You can do better! This way, you should get AIC, AICC and BIC :

options formdlim = '-';

PROC IMPORT OUT= WORK.BHCO

DATAFILE= "C:\Users\nacharti\Desktop\PhD\Nest survival analysis\Logistic regression BHCO\Data\bhco5.jmp"

DBMS=JMP REPLACE;

RUN;

Proc logistic data=BHCO desc;

model Parisitized = CaneStemAvg;

score out=drop fitstat;

ods output ScoreFitStat=AIC_CaneStemAvg;

run;

Proc logistic data=BHCO desc;

model Parisitized = CanCovAvg;

score out=drop fitstat;

ods output ScoreFitStat=AIC_CanCovAvg;

run;

Proc logistic data=BHCO desc;

model Parisitized = ForbAvg;

score out=drop fitstat;

ods output ScoreFitStat=AIC_ForbAvg;

run;

Proc logistic data=BHCO desc;

model Parisitized = TreeLg CanCovAvg;

score out=drop fitstat;

ods output ScoreFitStat=AIC_TreeLgCanCovAvg;

run;

Proc logistic data=BHCO desc;

model Parisitized = DenVerCV DenHorCV;

score out=drop fitstat;

ods output ScoreFitStat=AIC_DenVerCVDenHorCV;

run;

data allAIC;

set AIC_: INDSNAME=modelVars;

run;

proc print; run;

PG

PG
Swainsons
Fluorite | Level 6

PG,

Thank you very much for your time with my question.

When I ran the code in your reply of Mar 4, 2012 7:32 PM, this is the output:

The SAS System          12:15 Monday, March 5, 2012  76

                                                                    Intercept

                                              Intercept          And

                          Obs    Criterion      Only       Covariates

                           1        AIC          81.670       81.761

                           2        AIC          81.670       83.574

                           3        AIC          81.670       84.493

                           4        AIC          81.670       83.587

                           5        AIC          81.670       83.448

Obviously, I can see that it has produced AIC values. However, the AIC values for Obs 1-5 do not correspond to the sequential order of the models, so one needs to go to the output and see which AIC values correspond with each model? It would be great if there was a way to list the model "name" instead of just numerical values (1-5) for each Obs.

When I ran the code in your second reply of Mar 4, 2012 8:16 PM, for which you said I should get you should get AIC, AICC and BIC, this is the output:

  The SAS System          12:15 Monday, March 5, 2012  65

                     Obs     DataSet         Freq     LogLike    MisClass

                      1     WORK.BHCO         109    -38.8803      0.1193

                      2     WORK.BHCO         109    -39.7868      0.1193

                      3     WORK.BHCO         109    -39.2466      0.1193

                      4     WORK.BHCO         109    -39.7934      0.1193

                      5     WORK.BHCO         109    -38.7239      0.1193

Unfortunately, it does not show values for AIC, AICC and BIC?

Can you please assist further?

Thanks!

PGStats
Opal | Level 21

I'm working without being able to run complete tests. But we are making progress.

To correct the absence of reference to which model the AIC refers to, replace the last datastep by:

data allAIC;

set AIC_: INDSNAME=_modelVars;

modelVars = substr(_modelVars, 10);

run;

Were there any errors or warnings when you ran the program from my second reply?

PG
Swainsons
Fluorite | Level 6

Progress!

Here is the output from you reply of Mar 5, 2012 1:17 PM, which has solved the reference problem.

           The SAS System          12:15 Monday, March 5, 2012 151

           Obs     DataSet         Freq     LogLike    MisClass    modelVars

            1     WORK.BHCO         109    -38.8803      0.1193    CANCOVAVG

            2     WORK.BHCO         109    -39.7868      0.1193    CANESTEMAVG

            3     WORK.BHCO         109    -39.2466      0.1193    DENVERCVDENHORCV

            4     WORK.BHCO         109    -39.7934      0.1193    FORBAVG

            5     WORK.BHCO         109    -38.7239      0.1193    TREELGCANCOVAVG

There were no errors or warnings.

All that remains is to generate a value for AIC and AICC.

Thanks!

PGStats
Opal | Level 21

The same correction with my first reply will get you the AICs (but not the AICCs).

What version of SAS are you using? I'm using version 9.3 and getting all the stats described in

http://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_logistic_sec...

in the output datasets.

PG

PG
Swainsons
Fluorite | Level 6

I'm using 9.2 and not getting AICC.

Here is what I get:

Model Fit Statistics

                                                         Intercept

                                          Intercept            and

                            Criterion          Only     Covariates

                            AIC              81.670         84.493

                            SC               84.362         92.567

                            -2 Log L         79.670         78.493

PGStats
Opal | Level 21

The AICC is produced in response to the request :

score out=drop fitstat;

in version 9.3...

I just checked the FITSTAT documentation in version 9.2 :

http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_logistic_sec...

and only the four statistics that you got are produced. Smiley Sad

If you are using the AIC to compare models built on the same number of observations then it is very unlikely that you would get a different model ordering with AIC and AICC.

Best of luck.

PG

PG
Swainsons
Fluorite | Level 6

OK...I was afraid of that.  I will use the AIC values to compute AICC in Excel...just trying to avoid that step.

Thanks for getting me this far!

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
  • 11 replies
  • 8046 views
  • 7 likes
  • 2 in conversation