Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Code for a table with AIC and AICc in Proc logistic

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 03-04-2012 04:54 PM
(8496 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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 :

and only the four statistics that you got are produced.

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

11 REPLIES 11

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You can get AIC into dataset myAIC by adding the statement

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

to your proc logistic.

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

in the output datasets.

PG

PG

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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 :

and only the four statistics that you got are produced.

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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!

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. **Registration is now open through August 30th**. Visit the SAS Hackathon homepage.

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.