I posted this a while back.
/* This program generates all two way interactions.
It was written on 6/29/03 by David C. Airey, Ph.D.,
and meant to be used to aid testing a full model and
a reduced model with a general linear test, where
the full model has all interactions and the reduced
model has none. The general linear test is:
local F = ((`sser' - `ssef')/(`dfr' - `dff')) / (`ssef'/`dff')
local Fp = Ftail((`dfr'-`dff'),`dff', `F')
display `F', `Fp'
*/
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/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/