Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Creating interaction terms of 30 continuous variables


From   David Airey <david.airey@Vanderbilt.Edu>
To   Statalist <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Creating interaction terms of 30 continuous variables
Date   Wed, 9 Sep 2009 10:57:28 -0500

.

Try this...

program define atwi
        version 8
        syntax varlist(min = 2 numeric)
        local t : word count `varlist'
        tokenize `varlist'
        forvalues j = 1/`=`t'-1' {
                forvalues k = `=`j'+1'/`t' {
                        generate ``j''x``k'' = ``j''*``k''
                }
        }
end

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index