<?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 Re: Macro Variable List for Proc Logistic in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240052#M12699</link>
    <description>&lt;P&gt;You need to loop through all your variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the section on:&lt;/P&gt;
&lt;H4&gt;A macro program for repeating a procedure multiple times&lt;/H4&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/" target="_blank"&gt;http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Dec 2015 17:00:09 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-12-18T17:00:09Z</dc:date>
    <item>
      <title>Macro Variable List for Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240051#M12698</link>
      <description>&lt;P&gt;I have 5 binary predictors that I what to use in 5 simple logistic models, respectively. Though, this code outputs a single multiple logistic model with all 5 predictors in it. Help would be appreciated:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%Let variable = X1 X2 X3 X4 X5;
proc logistic data=mydata;
	class &amp;amp;variable (ref='0')		 	
				/ param=ref;
	model Y (event='Yes') = 
				&amp;amp;variable / lackfit FIRTH;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Dec 2015 16:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240051#M12698</guid>
      <dc:creator>H</dc:creator>
      <dc:date>2015-12-18T16:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable List for Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240052#M12699</link>
      <description>&lt;P&gt;You need to loop through all your variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the section on:&lt;/P&gt;
&lt;H4&gt;A macro program for repeating a procedure multiple times&lt;/H4&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/" target="_blank"&gt;http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 17:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240052#M12699</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-18T17:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable List for Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240059#M12700</link>
      <description>I would transpose the CLASS variables and use a BY statement in proc logistic; by _NAME_;  No macro variables or looping needed.</description>
      <pubDate>Fri, 18 Dec 2015 17:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240059#M12700</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-12-18T17:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable List for Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240094#M12702</link>
      <description>&lt;P&gt;Thanks to both of&amp;nbsp;you. I first quickly went with data_null_'s option, though it ceased because data were not sorted. I imagine that I would need to incorporate a proc sort into the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I then ended up using the link in the former post, which gave a comparable example, see below. I am going to tweak it to grab other components of the output.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mylogit2(all_indeps, outest);
  %let k=1;
  %let indep = %scan(&amp;amp;all_indeps, &amp;amp;k);
  %do %while("&amp;amp;indep" NE "");
    title "independent variable is &amp;amp;indep";
    proc logistic data=mydata des outest=_est&amp;amp;k;
     model Y (event='Yes') = &amp;amp;indep;
    run;
    %let k = %eval(&amp;amp;k + 1);
    %let indep = %scan(&amp;amp;all_indeps, &amp;amp;k);
  %end;
  %if "&amp;amp;outest" NE "" %then 
  %do;
    data &amp;amp;outest;
      set 
      %do i = 1 %to &amp;amp;k - 1;
        _est&amp;amp;i
      %end; 
      ;
    run;	  
    %let k = %eval(&amp;amp;k - 1);
    proc datasets;
      delete _est1 - _est&amp;amp;k;
    run;
  %end;
  %else 
  %do;
     %put no dataset name was provided, files are not combined;
  %end;
%mend;
%mylogit2(X1 X2 X3 X4 X5 X6 X7 X8 X9)

%mylogit2(X1 X2 X3 X4 X5 X6 X7 X8 X9, a)
proc print data = a;
  var intercept X1 X2 X3 X4 X5 X6 X7 X8 X9;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2015 21:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240094#M12702</guid>
      <dc:creator>H</dc:creator>
      <dc:date>2015-12-18T21:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable List for Proc Logistic</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240123#M12705</link>
      <description>&lt;P&gt;I highly recommend the transpose method. It makes it easier to capture all your results in one place for comparisons later on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Generate sample data;
data have;

array x(5) x1-x5;

do Record_ID=1 to 1000;
if rand('bernoulli', 0.3)=1 then Y='Yes';
else Y='No';

do j=1 to 5;
x(j)=rand('bernoulli', 1/j);
end;
output;
end;

drop J;
run;

*Transpose;
proc transpose data=have out=flipped (rename=(_name_=variable col1=Variable_Value));
BY Record_ID Y;
run;

*Resort;
proc sort data=flipped;
by variable;
run;

*Regression;
proc logistic data=flipped;
BY variable;
	class Variable_Value (ref='0')		 	
				/ param=ref;
	model Y (event='Yes') = 
				Variable_Value / lackfit FIRTH;
	ods output parameterestimates=Estimates;
run;

proc print data=Estimates;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Dec 2015 22:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Macro-Variable-List-for-Proc-Logistic/m-p/240123#M12705</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-18T22:03:03Z</dc:date>
    </item>
  </channel>
</rss>

