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!
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
You can get AIC into dataset myAIC by adding the statement
ods output FitStatistics=myAIC(where=(criterion="AIC"));
to your proc logistic.
PG
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;
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
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,
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!
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?
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!
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
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
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
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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.