<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Creating a table with AIC BIC for variable selection-logistic regression in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-with-AIC-BIC-for-variable-selection-logistic/m-p/905897#M40471</link>
    <description>&lt;P&gt;This is the SAS macro code my professor has used in one of his examples:&lt;/P&gt;&lt;PRE&gt;%MACRO logistic_aic_sbc_score(yvariable=,xvariables=,dataset=,minvar=,maxvar=); 

proc datasets;
delete allaicsbc;
run;

%LET nmodels=&amp;amp;maxvar-&amp;amp;minvar+1; 
%DO i= 1 %to &amp;amp;nmodels;

proc datasets;
delete aicsbc model_reg_logistic temp ;
run;

proc logistic data=&amp;amp;dataset  ;
model &amp;amp;yvariable(ref='0') = &amp;amp;xvariables / selection=score best=1 start=&amp;amp;minvar stop=&amp;amp;maxvar;
ods output stat.Logistic.BestSubsets=model_reg_logistic;
run;

data model_reg_logistic; set model_reg_logistic;
keep VariablesInModel;
run;

data temp; set model_reg_logistic;
if _N_ NE &amp;amp;i then delete;
run;

data _null_ ;
set temp;
call symputx('xvar',VariablesInModel);
run;

proc logistic data=&amp;amp;dataset  ;
model &amp;amp;yvariable(ref='0') = &amp;amp;xvar;
ods output Stat.Logistic.FitStatistics=aicsbc;
run; 
data aicsbc;set aicsbc;
drop InterceptOnly;
if criterion ="-2 Log L" then delete;
run;
proc transpose data=aicsbc out=aicsbc;
run;
data aicsbc;set aicsbc;
rename COL1=AIC COL2=SBC;
run;
data aicsbc;set aicsbc;
keep AIC SBC;
run;

proc append base=allaicsbc data=aicsbc force;
run;
%END;

data allaicsbc;
merge allaicsbc model_reg_logistic;
run;

proc print data=allaicsbc;
run;


%MEND logistic_aic_sbc_score;&lt;/PRE&gt;&lt;P&gt;and I would like to create a table for a file named pred3_num, here is the all subset search code for it:&lt;/P&gt;&lt;PRE&gt;proc logistic data=pred3_num;
class x5 x7 x8;
model y(ref='0') = x1 x2 x21 x22 x23 x24 x25 x26 x27 x28 x29 xx2 x3 x31 x4 x41 x42 x5-x8 x9 x91 x10 x11 x111 x112 x113 x114 x115 x116 x117 x118 x119 xx11 x12-x14 
x15 x151 x152 /
selection=score best=1;
run;&lt;/PRE&gt;&lt;P&gt;there 42 explanatory variables. I would like to know how I can modify that MACRO code in order to create a table for my pred3_num data set.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Sun, 03 Dec 2023 17:09:23 GMT</pubDate>
    <dc:creator>SIMMII</dc:creator>
    <dc:date>2023-12-03T17:09:23Z</dc:date>
    <item>
      <title>Creating a table with AIC BIC for variable selection-logistic regression</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-with-AIC-BIC-for-variable-selection-logistic/m-p/905897#M40471</link>
      <description>&lt;P&gt;This is the SAS macro code my professor has used in one of his examples:&lt;/P&gt;&lt;PRE&gt;%MACRO logistic_aic_sbc_score(yvariable=,xvariables=,dataset=,minvar=,maxvar=); 

proc datasets;
delete allaicsbc;
run;

%LET nmodels=&amp;amp;maxvar-&amp;amp;minvar+1; 
%DO i= 1 %to &amp;amp;nmodels;

proc datasets;
delete aicsbc model_reg_logistic temp ;
run;

proc logistic data=&amp;amp;dataset  ;
model &amp;amp;yvariable(ref='0') = &amp;amp;xvariables / selection=score best=1 start=&amp;amp;minvar stop=&amp;amp;maxvar;
ods output stat.Logistic.BestSubsets=model_reg_logistic;
run;

data model_reg_logistic; set model_reg_logistic;
keep VariablesInModel;
run;

data temp; set model_reg_logistic;
if _N_ NE &amp;amp;i then delete;
run;

data _null_ ;
set temp;
call symputx('xvar',VariablesInModel);
run;

proc logistic data=&amp;amp;dataset  ;
model &amp;amp;yvariable(ref='0') = &amp;amp;xvar;
ods output Stat.Logistic.FitStatistics=aicsbc;
run; 
data aicsbc;set aicsbc;
drop InterceptOnly;
if criterion ="-2 Log L" then delete;
run;
proc transpose data=aicsbc out=aicsbc;
run;
data aicsbc;set aicsbc;
rename COL1=AIC COL2=SBC;
run;
data aicsbc;set aicsbc;
keep AIC SBC;
run;

proc append base=allaicsbc data=aicsbc force;
run;
%END;

data allaicsbc;
merge allaicsbc model_reg_logistic;
run;

proc print data=allaicsbc;
run;


%MEND logistic_aic_sbc_score;&lt;/PRE&gt;&lt;P&gt;and I would like to create a table for a file named pred3_num, here is the all subset search code for it:&lt;/P&gt;&lt;PRE&gt;proc logistic data=pred3_num;
class x5 x7 x8;
model y(ref='0') = x1 x2 x21 x22 x23 x24 x25 x26 x27 x28 x29 xx2 x3 x31 x4 x41 x42 x5-x8 x9 x91 x10 x11 x111 x112 x113 x114 x115 x116 x117 x118 x119 xx11 x12-x14 
x15 x151 x152 /
selection=score best=1;
run;&lt;/PRE&gt;&lt;P&gt;there 42 explanatory variables. I would like to know how I can modify that MACRO code in order to create a table for my pred3_num data set.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2023 17:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-with-AIC-BIC-for-variable-selection-logistic/m-p/905897#M40471</guid>
      <dc:creator>SIMMII</dc:creator>
      <dc:date>2023-12-03T17:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with AIC BIC for variable selection-logistic regression</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-with-AIC-BIC-for-variable-selection-logistic/m-p/905898#M40472</link>
      <description>&lt;P&gt;Is the problem that in the macro the code for PROC LOGISTIC does not have a CLASS statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or is there some other problem? In that case you need to explain further.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2023 17:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-with-AIC-BIC-for-variable-selection-logistic/m-p/905898#M40472</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-12-03T17:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with AIC BIC for variable selection-logistic regression</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-with-AIC-BIC-for-variable-selection-logistic/m-p/905899#M40473</link>
      <description>&lt;P&gt;This is log for the first bit:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         %logistic_aic_sbc_score(yvariable=y,xvariables=x1 x2 x21 x22 x23 x24 x25 x26 x27 x28 x29 xx2 x3 x31 x4 x41 x42 x5-x8 x9
 69       ! x91 x10 x11 x111 x112 x113 x114 x115 x116 x117 x118 x119 xx11 x12-x14
 70         x15 x151 x152,dataset=pred3_num,minvar=1,maxvar=42);
 
 NOTE: Deleting WORK.ALLAICSBC (memtype=DATA).
 
 NOTE: PROCEDURE DATASETS used (Total process time):
       real time           0.02 seconds
       user cpu time       0.02 seconds
       system cpu time     0.00 seconds
       memory              1557.21k
       OS Memory           24228.00k
       Timestamp           12/03/2023 05:20:18 PM
       Step Count                        1059  Switch Count  2
       Page Faults                       0
       Page Reclaims                     102
       Page Swaps                        0
       Voluntary Context Switches        18
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           16
       
 
 
 NOTE: Deleting WORK.AICSBC (memtype=DATA).
 NOTE: Deleting WORK.MODEL_REG_LOGISTIC (memtype=DATA).
 NOTE: Deleting WORK.TEMP (memtype=DATA).
 
 NOTE: PROCEDURE DATASETS used (Total process time):
       real time           0.02 seconds
       user cpu time       0.02 seconds
       system cpu time     0.00 seconds
       memory              651.34k
       OS Memory           24228.00k
       Timestamp           12/03/2023 05:20:18 PM
       Step Count                        1060  Switch Count  6
       Page Faults                       0
       Page Reclaims                     58
       Page Swaps                        0
       Voluntary Context Switches        46
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           24
       
 
 ERROR: Variable x5 should be either numeric or specified in the CLASS statement.&lt;/PRE&gt;&lt;P&gt;The log is generating hundreds of other errors, if I include a class statement do you think it will fix most of my other errors? If so, where should I include the class statement in the macro?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2023 17:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-with-AIC-BIC-for-variable-selection-logistic/m-p/905899#M40473</guid>
      <dc:creator>SIMMII</dc:creator>
      <dc:date>2023-12-03T17:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with AIC BIC for variable selection-logistic regression</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-with-AIC-BIC-for-variable-selection-logistic/m-p/905900#M40474</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/453974"&gt;@SIMMII&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;
&lt;P&gt;The log is generating hundreds of other errors, if I include a class statement do you think it will fix most of my other errors? If so, where should I include the class statement in the macro?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The CLASS statement should fix the X5 problem. With regards to the other errors, it is impossible for me to answer since you didn't show us the other errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CLASS statement should go in the macro in the exact same place as it goes in your non-macro code. You probably need modify the macro definition to include a macro parameter containing the list of CLASS variables as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you run a macro in SAS, you ought to turn on macro debugging tools, specifically run this line of code before you run the macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Although I question why you need a macro here when you already have written PROC LOGISTIC code that seems to do what you want.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Dec 2023 17:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-with-AIC-BIC-for-variable-selection-logistic/m-p/905900#M40474</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-12-03T17:32:12Z</dc:date>
    </item>
  </channel>
</rss>

