<?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: Automatic generation of all possible interaction terms (no duplicates) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341762#M78272</link>
    <description>&lt;P&gt;Yes, they should be included. Alphabetic names are arbitrary.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2017 20:57:28 GMT</pubDate>
    <dc:creator>MetinBulus</dc:creator>
    <dc:date>2017-03-16T20:57:28Z</dc:date>
    <item>
      <title>Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341748#M78262</link>
      <description>&lt;P&gt;Hi all, I have been trying to find a way to create all possbile interactions for a procedure. The problem is, for example a*b interaction is same as b*a and I couldn't find a reasonable way to exclude these duplicates. Here is how I started:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data data;
	input var $ @@;
	cards; 
		a b c d e f g h i j k 
	;
run;
data temp;
	set data;
run;
proc sql noprint;
	select strip(d.var)||"*"||strip(t.var) into :interactions separated by " "
		from data as d, temp as t;
quit;
%put &amp;amp;interactions;&lt;/PRE&gt;
&lt;P&gt;And here is the result:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%put &amp;amp;interactions;
a*a a*b a*c a*d a*e a*f a*g a*h a*i a*j a*k b*a b*b b*c b*d b*e b*f b*g b*h b*i b*j b*k c*a c*b
c*c c*d c*e c*f c*g c*h c*i c*j c*k d*a d*b d*c d*d d*e d*f d*g d*h d*i d*j d*k e*a e*b e*c e*d
e*e e*f e*g e*h e*i e*j e*k f*a f*b f*c f*d f*e f*f f*g f*h f*i f*j f*k g*a g*b g*c g*d g*e g*f
g*g g*h g*i g*j g*k h*a h*b h*c h*d h*e h*f h*g h*h h*i h*j h*k i*a i*b i*c i*d i*e i*f i*g i*h
i*i i*j i*k j*a j*b j*c j*d j*e j*f j*g j*h j*i j*j j*k k*a k*b k*c k*d k*e k*f k*g k*h k*i k*j
k*k
&lt;/PRE&gt;
&lt;P&gt;Please help!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 20:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341748#M78262</guid>
      <dc:creator>MetinBulus</dc:creator>
      <dc:date>2017-03-16T20:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341753#M78265</link>
      <description>&lt;P&gt;What proc are you using? Have you tried the using the | in the model statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc glm data=sashelp.cars;
    model mpg_city = horsepower | weight | length | cylinders @2;
run;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 20:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341753#M78265</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-16T20:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341754#M78266</link>
      <description>&lt;P&gt;It looks like you should be able to add one of these two WHERE clauses:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where d.var &amp;lt; t.var&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where d.var &amp;lt;= t.var&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depends on whether you want a*a, b*b, c*c, etc. as part of the list.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 20:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341754#M78266</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-16T20:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341757#M78269</link>
      <description>&lt;P&gt;And if you do decide to go down that route still, you don't need the temp data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data;
	input var $ @@;
	cards; 
		a b c d e f g h i j k 
	;
run;

proc sql noprint;
	select catx('*', d1.var, d2.var) into :interactions separated by " "
		from data as d1, data as d2
        where d1.var &amp;gt; d2.var;

quit;
%put &amp;amp;interactions;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 20:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341757#M78269</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-16T20:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341761#M78271</link>
      <description>&lt;P&gt;I am using proc logistic, the code is embedded within a macro and number of variables are not known in advance. This creates a pool of higher order terms to be tried.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 20:56:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341761#M78271</guid>
      <dc:creator>MetinBulus</dc:creator>
      <dc:date>2017-03-16T20:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341762#M78272</link>
      <description>&lt;P&gt;Yes, they should be included. Alphabetic names are arbitrary.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 20:57:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341762#M78272</guid>
      <dc:creator>MetinBulus</dc:creator>
      <dc:date>2017-03-16T20:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341763#M78273</link>
      <description>&lt;P&gt;Thanks it is much better this way.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 20:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341763#M78273</guid>
      <dc:creator>MetinBulus</dc:creator>
      <dc:date>2017-03-16T20:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341765#M78275</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/24060"&gt;@MetinBulus&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi all, I have been trying to find a way to create all possbile interactions for a procedure. The problem is, for example a*b interaction is same as b*a and I couldn't find a reasonable way to exclude these duplicates. Here is how I started:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data data;
	input var $ @@;
	cards; 
		a b c d e f g h i j k 
	;
run;
data temp;
	set data;
run;
proc sql noprint;
	select strip(d.var)||"*"||strip(t.var) into :interactions separated by " "
		from data as d, temp as t;
quit;
%put &amp;amp;interactions;&lt;/PRE&gt;
&lt;P&gt;And here is the result:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%put &amp;amp;interactions;
a*a a*b a*c a*d a*e a*f a*g a*h a*i a*j a*k b*a b*b b*c b*d b*e b*f b*g b*h b*i b*j b*k c*a c*b
c*c c*d c*e c*f c*g c*h c*i c*j c*k d*a d*b d*c d*d d*e d*f d*g d*h d*i d*j d*k e*a e*b e*c e*d
e*e e*f e*g e*h e*i e*j e*k f*a f*b f*c f*d f*e f*f f*g f*h f*i f*j f*k g*a g*b g*c g*d g*e g*f
g*g g*h g*i g*j g*k h*a h*b h*c h*d h*e h*f h*g h*h h*i h*j h*k i*a i*b i*c i*d i*e i*f i*g i*h
i*i i*j i*k j*a j*b j*c j*d j*e j*f j*g j*h j*i j*j j*k k*a k*b k*c k*d k*e k*f k*g k*h k*i k*j
k*k
&lt;/PRE&gt;
&lt;P&gt;Please help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This example right out of the documentation for LEXCOMB.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;29         data _null_;
30            array x[11] $1 ('a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k');
31            n=dim(x);
32            k=2;
33            ncomb=comb(n, k);
34            do j=1 to ncomb;
35               call lexcomb(j, k, of x[*]);
36               put j 5. +3 x1 +(-1) '*' x2;
37               end;
38            run;

    1   a*b
    2   a*c
    3   a*d
    4   a*e
    5   a*f
    6   a*g
    7   a*h
    8   a*i
    9   a*j
   10   a*k
   11   b*c
   12   b*d
   13   b*e
   14   b*f
   15   b*g
   16   b*h
   17   b*i
   18   b*j
   19   b*k
   20   c*d
   21   c*e
   22   c*f
   23   c*g
   24   c*h
   25   c*i
   26   c*j
   27   c*k
   28   d*e
   29   d*f
   30   d*g
   31   d*h
   32   d*i
   33   d*j
   34   d*k
   35   e*f
   36   e*g
   37   e*h
   38   e*i
   39   e*j
   40   e*k
   41   f*g
   42   f*h
   43   f*i
   44   f*j
   45   f*k
   46   g*h
   47   g*i
   48   g*j
   49   g*k
   50   h*i
   51   h*j
   52   h*k
   53   i*j
   54   i*k
   55   j*k&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 20:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341765#M78275</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-03-16T20:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341767#M78276</link>
      <description>&lt;P&gt;This is great, thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 21:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341767#M78276</guid>
      <dc:creator>MetinBulus</dc:creator>
      <dc:date>2017-03-16T21:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341777#M78282</link>
      <description>&lt;P&gt;Another way that &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; alluded to it to use GLMMOD to create and OUTPARM data set.&amp;nbsp; This also include the one-way effects which you may or may not want and can remove easily enough.&amp;nbsp; Depending on what you're doing this output may be more useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data glmmod;
   array x[11] a b c d e f g h i j k (11*1);
   y = 1;
   output;
   run;
proc glmmod outparm=parm noprint;
   class a--k;
   model y = a|b|c|d|e|f|g|h|i|j|k @2;
   run;
proc print;
   run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG title="Capture.PNG" alt="Capture.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/7796i36A340D988A80349/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 21:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341777#M78282</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-03-16T21:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341796#M78289</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/24060"&gt;@MetinBulus&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I am using proc logistic, the code is embedded within a macro and number of variables are not known in advance. This creates a pool of higher order terms to be tried.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So? All that would change would be the parameter list with the bars in between? Nothing else is required.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 22:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341796#M78289</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-16T22:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341805#M78294</link>
      <description>This might work as well, it is easier to generate quadratic terms by subsetting and multiplying main effects to complete the list.</description>
      <pubDate>Thu, 16 Mar 2017 22:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341805#M78294</guid>
      <dc:creator>MetinBulus</dc:creator>
      <dc:date>2017-03-16T22:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341838#M78299</link>
      <description>&lt;P&gt;My goal is not to estimate but to create a list from which I can extract (or delete) terms. Solutions provided are sufficient to create such a list after adding quadratic terms. I haven't tried this approach but a dry run in proc logistic or glmmod may help too. Thank you, great suggestions, I am learning a lot along the way.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 02:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341838#M78299</guid>
      <dc:creator>MetinBulus</dc:creator>
      <dc:date>2017-03-17T02:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic generation of all possible interaction terms (no duplicates)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341846#M78305</link>
      <description>&lt;P&gt;I was not aware that this solution could work everytime, after I failed&amp;nbsp;at others. Thanks a lot! Amazing!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 03:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automatic-generation-of-all-possible-interaction-terms-no/m-p/341846#M78305</guid>
      <dc:creator>MetinBulus</dc:creator>
      <dc:date>2017-03-17T03:27:59Z</dc:date>
    </item>
  </channel>
</rss>

