<?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: do loop / macro for pairwise interactions in regression analysis in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554988#M154437</link>
    <description>&lt;P&gt;From a statistical point of view, I am skeptical that this is a valid method of determining what terms should go in the model. I have never seen anyone try to fit each possible interaction, one at a time, with all of the main effects, into a sequence of models. Not only would it not be clear what to do with this information once you perform the analysis, I think you will run into a lot of the same problems that plague stepwise regression, and so I feel that there must be a better approach, but since I don't really understand what your goal is, I can't advise further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bottom line: just because you (or someone) can program this, doesn't mean you should program this.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Apr 2019 12:10:55 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-04-30T12:10:55Z</dc:date>
    <item>
      <title>do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554860#M154386</link>
      <description>&lt;P&gt;I am trying to create a macro to loop through all possible pairwise interactions in a regression analysis. I am using the Imbens and Rubin approach to estimating a propensity score. I have selected my main effects and now I want to test for possible pairwise interactions to retain in the regression model. I need to include a number of forced variables (currently written for 12) and then test one pairwise interaction at a time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All but one (momage) of my variables are dichotomous (dummy) vars, but I want the macro to be able to handle either dichotomous or quantitative variables. e.g. iterate through all possible interactions and I can ignore the ones I don't need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the attached code, I have tried to pass my main effects into an array, and then use a do loop to generate the interaction variables from the array. Those array variables should then pass into the macro and repeat until all pairwise interactions are tested.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get two errors with this code&lt;/P&gt;&lt;P&gt;1)&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: SAS set option OBS=0 and will continue to check statements.&lt;BR /&gt;This may cause NOTE: No observations in data set.&lt;BR /&gt;WARNING: The data set WORK.WNHEST may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 161 variables.&lt;/P&gt;&lt;P&gt;2)&amp;nbsp;&lt;/P&gt;&lt;P&gt;MLOGIC(PAIRWISEINT): Ending execution.&lt;BR /&gt;ERROR 117-185: There were 2 unclosed DO blocks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have read the information about using the BY statement with a transformed dataset (&lt;A href="https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html&lt;/A&gt;) but I don't see how to get the interactions fed into the regressions this way.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought about using %DO within the macro but the order didn't make sense to me that way, I think it should be array -&amp;gt; generate interaction terms -&amp;gt; terms go into macro input and then used in regression.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there are any recommendations on additional reading I welcome those too. Thanks in advance!&lt;/P&gt;&lt;P&gt;SAS Software 9.2 (TS2M3)&lt;BR /&gt;Linux 2.6.18-402.el5PAE (LINUX) platform&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	input msdp momage nomarnopn nomarpn marnopn momedu1 momedu3 momedu4 momedu5 bmi_un bmi_ov bmi_ob moborn;
	CARDS;
1 19 1 0 0 1 0 0 0 0 0 0 1
1 20 0 1 0 0 0 0 0 1 0 0 0
1 21 0 0 1 0 0 1 0 0 1 0 1
1 23 0 1 0 0 0 0 1 0 0 1 0
1 25 1 0 0 0 0 1 0 0 1 0 1
0 27 0 1 0 0 1 0 0 1 0 0 0
0 29 0 0 0 0 0 0 0 0 0 0 1
0 31 0 1 0 1 0 0 0 1 0 0 0
0 33 0 0 1 0 1 0 0 0 1 0 1
0 35 0 0 0 0 0 0 0 0 0 1 0
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;OPTIONS mprint symbolgen mlogic spool;
%MACRO pairwiseint(data=, x1=, x2=, x3=, x4=, x5=, x6=, x7=, x8=, x9=, x10=, x11=, x12=, xi= , xj= , nummainefx=, outcome=, penter=, pkeep=);
proc logistic data=&amp;amp;data DESCENDING;
 class
   &amp;amp;x2 &amp;amp;x3 &amp;amp;x4 &amp;amp;x5 &amp;amp;x6 &amp;amp;x7 &amp;amp;x8 &amp;amp;x9 &amp;amp;x10 &amp;amp;x11 &amp;amp;x12
   / PARAM=REF;
 model &amp;amp;outcome(event='1') = &amp;amp;x1 &amp;amp;x2 &amp;amp;x3 &amp;amp;x4 &amp;amp;x5 &amp;amp;x6 &amp;amp;x7 &amp;amp;x8 &amp;amp;x9 &amp;amp;x10 &amp;amp;x11 &amp;amp;x12
  &amp;amp;xi*&amp;amp;xj
  /include=&amp;amp;nummainefx selection=stepwise slentry=&amp;amp;penter slstay=&amp;amp;pkeep
  details
  lackfit;
%MEND pairwiseint;

*set arrays for macro variables;
*keep xi the same;
*the number is the number of main effects in the model;
*then define main effect variables;
data wnhest;
        set wnhest;
array main {12} momage nomarnopn nomarpn marnopn momedu1 momedu3 momedu4 momedu5 bmi_un bmi_ov bmi_ob moborn;

DO i = 1 to 12 by 1;
  Do j = i to 12 by 1;
   xi=main[i];
   xj=main[j];
%pairwiseint(data=wnhest, x1=momage, x2=nomarnopn, x3=nomarpn, x4=marnopn, x5=momedu1, x6=momedu3, x7=momedu4, x8=momedu5, x9=bmi_un, x10=bmi_ov, x11=bmi_ob, x12=moborn, xi=xi, xj=xj, nummainefx=12, outcome=msdp, penter=.35, pkeep=.95);
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Apr 2019 21:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554860#M154386</guid>
      <dc:creator>anhl1206</dc:creator>
      <dc:date>2019-04-29T21:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554861#M154387</link>
      <description>&lt;P&gt;You cannot write a PROC statement in the middle of DATA step.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 21:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554861#M154387</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-29T21:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554868#M154389</link>
      <description>&lt;P&gt;Figure out what SAS code you want to generate. Then you can design your macro.&lt;/P&gt;
&lt;P&gt;Looks like you want something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO pairwiseint
(data=
,vars=
,nummainefx=
,outcome=
,penter=
,pkeep=
);
%local i j;
%do i=1 %to %sysfunc(countw(&amp;amp;vars,%str( )));
%do j=%eval(&amp;amp;i+1) %to %sysfunc(countw(&amp;amp;vars,%str( )));
proc logistic data=&amp;amp;data DESCENDING;
 class &amp;amp;vars / PARAM=REF;
 model &amp;amp;outcome(event='1') = &amp;amp;vars %scan(&amp;amp;vars,&amp;amp;i,%str( ))*%scan(&amp;amp;vars,&amp;amp;j,%str( ))
  /include=&amp;amp;nummainefx selection=stepwise slentry=&amp;amp;penter slstay=&amp;amp;pkeep
  details
  lackfit;
run;
%end ;
%end;
%MEND pairwiseint;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Apr 2019 21:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554868#M154389</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-29T21:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554869#M154390</link>
      <description>&lt;P&gt;Thanks very much for this suggestion! I will work with this for now. Thanks again for the help!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 21:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554869#M154390</guid>
      <dc:creator>anhl1206</dc:creator>
      <dc:date>2019-04-29T21:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554872#M154392</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/182179"&gt;@anhl1206&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to create a macro to loop through all possible pairwise interactions in a regression analysis. I am using the Imbens and Rubin approach to estimating a propensity score. I have selected my main effects and now I want to test for possible pairwise interactions to retain in the regression model. I need to include a number of forced variables (currently written for 12) and then test one pairwise interaction at a time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All but one (momage) of my variables are dichotomous (dummy) vars, but I want the macro to be able to handle either dichotomous or quantitative variables. e.g. iterate through all possible interactions and I can ignore the ones I don't need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the attached code, I have tried to pass my main effects into an array, and then use a do loop to generate the interaction variables from the array. Those array variables should then pass into the macro and repeat until all pairwise interactions are tested.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get two errors with this code&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: SAS set option OBS=0 and will continue to check statements.&lt;BR /&gt;This may cause NOTE: No observations in data set.&lt;BR /&gt;WARNING: The data set WORK.WNHEST may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 161 variables.&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MLOGIC(PAIRWISEINT): Ending execution.&lt;BR /&gt;ERROR 117-185: There were 2 unclosed DO blocks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have read the information about using the BY statement with a transformed dataset (&lt;A href="https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html&lt;/A&gt;) but I don't see how to get the interactions fed into the regressions this way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought about using %DO within the macro but the order didn't make sense to me that way, I think it should be array -&amp;gt; generate interaction terms -&amp;gt; terms go into macro input and then used in regression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are any recommendations on additional reading I welcome those too. Thanks in advance!&lt;/P&gt;
&lt;P&gt;SAS Software 9.2 (TS2M3)&lt;BR /&gt;Linux 2.6.18-402.el5PAE (LINUX) platform&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	input msdp momage nomarnopn nomarpn marnopn momedu1 momedu3 momedu4 momedu5 bmi_un bmi_ov bmi_ob moborn;
	CARDS;
1 19 1 0 0 1 0 0 0 0 0 0 1
1 20 0 1 0 0 0 0 0 1 0 0 0
1 21 0 0 1 0 0 1 0 0 1 0 1
1 23 0 1 0 0 0 0 1 0 0 1 0
1 25 1 0 0 0 0 1 0 0 1 0 1
0 27 0 1 0 0 1 0 0 1 0 0 0
0 29 0 0 0 0 0 0 0 0 0 0 1
0 31 0 1 0 1 0 0 0 1 0 0 0
0 33 0 0 1 0 1 0 0 0 1 0 1
0 35 0 0 0 0 0 0 0 0 0 1 0
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;OPTIONS mprint symbolgen mlogic spool;
%MACRO pairwiseint(data=, x1=, x2=, x3=, x4=, x5=, x6=, x7=, x8=, x9=, x10=, x11=, x12=, xi= , xj= , nummainefx=, outcome=, penter=, pkeep=);
proc logistic data=&amp;amp;data DESCENDING;
 class
   &amp;amp;x2 &amp;amp;x3 &amp;amp;x4 &amp;amp;x5 &amp;amp;x6 &amp;amp;x7 &amp;amp;x8 &amp;amp;x9 &amp;amp;x10 &amp;amp;x11 &amp;amp;x12
   / PARAM=REF;
 model &amp;amp;outcome(event='1') = &amp;amp;x1 &amp;amp;x2 &amp;amp;x3 &amp;amp;x4 &amp;amp;x5 &amp;amp;x6 &amp;amp;x7 &amp;amp;x8 &amp;amp;x9 &amp;amp;x10 &amp;amp;x11 &amp;amp;x12
  &amp;amp;xi*&amp;amp;xj
  /include=&amp;amp;nummainefx selection=stepwise slentry=&amp;amp;penter slstay=&amp;amp;pkeep
  details
  lackfit;
%MEND pairwiseint;

*set arrays for macro variables;
*keep xi the same;
*the number is the number of main effects in the model;
*then define main effect variables;
data wnhest;
        set wnhest;
array main {12} momage nomarnopn nomarpn marnopn momedu1 momedu3 momedu4 momedu5 bmi_un bmi_ov bmi_ob moborn;

DO i = 1 to 12 by 1;
  Do j = i to 12 by 1;
   xi=main[i];
   xj=main[j];
%pairwiseint(data=wnhest, x1=momage, x2=nomarnopn, x3=nomarpn, x4=marnopn, x5=momedu1, x6=momedu3, x7=momedu4, x8=momedu5, x9=bmi_un, x10=bmi_ov, x11=bmi_ob, x12=moborn, xi=xi, xj=xj, nummainefx=12, outcome=msdp, penter=.35, pkeep=.95);
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can you show what your code is supposed to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think you need all that macro stuff&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	input msdp momage nomarnopn nomarpn marnopn momedu1 momedu3 momedu4 momedu5 bmi_un bmi_ov bmi_ob moborn;
	CARDS;
1 19 1 0 0 1 0 0 0 0 0 0 1
1 20 0 1 0 0 0 0 0 1 0 0 0
1 21 0 0 1 0 0 1 0 0 1 0 1
1 23 0 1 0 0 0 0 1 0 0 1 0
1 25 1 0 0 0 0 1 0 0 1 0 1
0 27 0 1 0 0 1 0 0 1 0 0 0
0 29 0 0 0 0 0 0 0 0 0 0 1
0 31 0 1 0 1 0 0 0 1 0 0 0
0 33 0 0 1 0 1 0 0 0 1 0 1
0 35 0 0 0 0 0 0 0 0 0 1 0
;
RUN;
proc print;
   run;
%let x=momage nomarnopn nomarpn marnopn momedu1 momedu3 momedu4 momedu5 bmi_un bmi_ov bmi_ob moborn;
%let xat=%sysfunc(transtrn(%superq(x),%str( ),|));
%put NOTE: &amp;amp;=xat; 
proc logistic;
   *class &amp;amp;x / PARAM=REF;;
   model msdp = &amp;amp;xat@2 /stepwise;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Apr 2019 22:02:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554872#M154392</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-04-29T22:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554873#M154393</link>
      <description>&lt;P&gt;Since you want the names of the variables&lt;/P&gt;
&lt;P&gt;you do not want anything like this :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; xi&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;main&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; xj&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;main&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;j&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;as that gets the values of the variables and not the names. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Using a set statement you would be generating one call to your macro for each record in the data set. Which would be terribly redundant.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Your loop is inefficient as you would be using msdp * momage&amp;nbsp;&amp;nbsp;&amp;nbsp; and&amp;nbsp;&amp;nbsp; momage&amp;nbsp;* msdp in the interactions, which other that order of appearance in the output will be awful similar in result.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Please go back to the designing board, use something with only 3 or maybe 4 variables and show what PROC LOGISTIC code you need to generate for that example. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;I don't get what you were attempting to do with your Test data set because you did not use it anywhere.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Likely you do not need anywhere that many macro variables. I see a need for one macro variable to hold the names of CLASS variables, another to hold other variables on the model, X1 to Xn for each single variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;For your consideration:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;%macro pairloop (ovars= , classvars=);
   %let varlist = &amp;amp;ovars. &amp;amp;classvars.;
   %do i = 1 %to %eval(%sysfunc(countw(&amp;amp;varlist.))-1);
      %do j= %eval(&amp;amp;i.+1) %to %sysfunc(countw(&amp;amp;varlist.));
      %let var1= %scan(&amp;amp;varlist.,&amp;amp;i.);
      %let var2= %scan(&amp;amp;varlist.,&amp;amp;j.);
      %put var1 is &amp;amp;var1. , var2 is &amp;amp;var2.;
      /* HERE is where the proc logistic code would go using the variables*/
      %end;
   %end;
%mend;

%pairloop (ovars= msdp , classvars= momage nomarnopn nomarpn marnopn momedu1 momedu3 )

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 22:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554873#M154393</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-29T22:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554874#M154394</link>
      <description>&lt;P&gt;Thanks for this suggestion!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the | for all pairwise interactions, but this doesn't let me use the INCLUDE option in the regression in the correct format. I currently have a macro working for what I need like this:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO testint6(data=, x1=, x2=, x3=, x4=, x5=, x6=, x7=, x8=, x9=, x10=, x11=, x12=, x13=, x14=, x15=, x16=, x17=, nummainefx=, outcome=, penter=, pkeep=);

*4;
proc logistic data=&amp;amp;data DESCENDING;
        class
           &amp;amp;x2 &amp;amp;x3 &amp;amp;x4 &amp;amp;x5 &amp;amp;x6 &amp;amp;x7 &amp;amp;x8 &amp;amp;x9 &amp;amp;x10 &amp;amp;x11 &amp;amp;x12
                / PARAM=REF;
        model &amp;amp;outcome(event='1') = &amp;amp;x1 &amp;amp;x2 &amp;amp;x3 &amp;amp;x4 &amp;amp;x5 &amp;amp;x6 &amp;amp;x7 &amp;amp;x8 &amp;amp;x9 &amp;amp;x10 &amp;amp;x11 &amp;amp;x12 &amp;amp;x13 &amp;amp;x14 &amp;amp;x15 &amp;amp;x16 &amp;amp;x17
                &amp;amp;x1*&amp;amp;x4
        /include=&amp;amp;nummainefx selection=stepwise slentry=&amp;amp;penter slstay=&amp;amp;pkeep
        details
        lackfit;
run;
*5;
proc logistic data=&amp;amp;data DESCENDING;
        class
           &amp;amp;x2 &amp;amp;x3 &amp;amp;x4 &amp;amp;x5 &amp;amp;x6 &amp;amp;x7 &amp;amp;x8 &amp;amp;x9 &amp;amp;x10 &amp;amp;x11 &amp;amp;x12
                / PARAM=REF;
        model &amp;amp;outcome(event='1') = &amp;amp;x1 &amp;amp;x2 &amp;amp;x3 &amp;amp;x4 &amp;amp;x5 &amp;amp;x6 &amp;amp;x7 &amp;amp;x8 &amp;amp;x9 &amp;amp;x10 &amp;amp;x11 &amp;amp;x12 &amp;amp;x13 &amp;amp;x14 &amp;amp;x15 &amp;amp;x16 &amp;amp;x17
                &amp;amp;x1*&amp;amp;x5
        /include=&amp;amp;nummainefx selection=stepwise slentry=&amp;amp;penter slstay=&amp;amp;pkeep
        details
        lackfit;
run;
...

*67;
proc logistic data=&amp;amp;data DESCENDING;
class
&amp;amp;x2 &amp;amp;x3 &amp;amp;x4 &amp;amp;x5 &amp;amp;x6 &amp;amp;x7 &amp;amp;x8 &amp;amp;x9 &amp;amp;x10 &amp;amp;x11 &amp;amp;x12
/ PARAM=REF;
model &amp;amp;outcome(event='1') = &amp;amp;x1 &amp;amp;x2 &amp;amp;x3 &amp;amp;x4 &amp;amp;x5 &amp;amp;x6 &amp;amp;x7 &amp;amp;x8 &amp;amp;x9 &amp;amp;x10 &amp;amp;x11 &amp;amp;x12 &amp;amp;x13 &amp;amp;x14 &amp;amp;x15 &amp;amp;x16 &amp;amp;x17
&amp;amp;x11*&amp;amp;x12
/include=&amp;amp;nummainefx selection=stepwise slentry=&amp;amp;penter slstay=&amp;amp;pkeep
details
lackfit;
run;
%mend testint6;

%testint6(data=wnhest, x1=momage, x2=nomarnopn, x3=nomarpn, x4=marnopn, x5=momedu1, x6=momedu3, x7=momedu4,
x8=momedu5, x9=bmi_un, x10=bmi_ov, x11=bmi_ob, x12=moborn, x13=momage*momage, x14=nomarpn*momedu1, x15=momage*nomarnopn,
x16=momage*nomarpn, x17=momage*momedu4, nummainefx=17, outcome=msdp, penter=.35, pkeep=.95);

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I always need the x1-x12 variables included, and then one model at a time test one interaction between x1-x12 vars. The existing macro requires a lot of copy/pasting to change the MODEL line every time an interaction is retained.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will look into feeding in the x1-x12 as a list instead of specifying in the macro every time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 22:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554874#M154394</guid>
      <dc:creator>anhl1206</dc:creator>
      <dc:date>2019-04-29T22:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554875#M154395</link>
      <description>&lt;P&gt;Thanks for the explanations and the suggestions, I will go back to the drawing board.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 22:19:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554875#M154395</guid>
      <dc:creator>anhl1206</dc:creator>
      <dc:date>2019-04-29T22:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554988#M154437</link>
      <description>&lt;P&gt;From a statistical point of view, I am skeptical that this is a valid method of determining what terms should go in the model. I have never seen anyone try to fit each possible interaction, one at a time, with all of the main effects, into a sequence of models. Not only would it not be clear what to do with this information once you perform the analysis, I think you will run into a lot of the same problems that plague stepwise regression, and so I feel that there must be a better approach, but since I don't really understand what your goal is, I can't advise further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bottom line: just because you (or someone) can program this, doesn't mean you should program this.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 12:10:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/554988#M154437</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-30T12:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/555203#M154497</link>
      <description>&lt;P&gt;Thanks for the comment, and in pretty much any other case I agree that this would be inappropriate. The goal of this analysis is to estimate a propensity score, which is then used in subsequent analysis with the subclassification approach (split into quantiles and analysis happens within quantiles, to achieve balanced comparisons). Following the Imbens and Rubin approach, the rationale is that the balancing of covariates is the goal of this step of the analysis. Any hypothesis testing occurs after the covariate balancing by the propensity score.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 20:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/555203#M154497</guid>
      <dc:creator>anhl1206</dc:creator>
      <dc:date>2019-04-30T20:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/555206#M154498</link>
      <description>&lt;P&gt;Ok, so that is an application I am not familiar with. Does not the code provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;in message 3 solve the problem?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 20:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/555206#M154498</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-30T20:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: do loop / macro for pairwise interactions in regression analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/555215#M154499</link>
      <description>&lt;P&gt;I was able to implement this and it worked! Thanks to all for the suggestions and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; for the ultimate solution, they were helpful to me learning how to use the macro language in my analyses!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 21:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-macro-for-pairwise-interactions-in-regression-analysis/m-p/555215#M154499</guid>
      <dc:creator>anhl1206</dc:creator>
      <dc:date>2019-04-30T21:02:35Z</dc:date>
    </item>
  </channel>
</rss>

