This puts the variable list into local macro `vars', then grabs the
variables sequentially from the list. The inner loop (y) only goes up
to the variable prior to the current outer loop (x) variable, which
means we create only one version of each interaction and avoid creating
the squares of each variable as well.

Or, in Stata 11, you can specify all the interactions with factor
varlists, without creating any interaction variables at all. For
example, to regress variable myvar on all the interactions:

I am trying to explore all possible interaction terms in my dataset
and I am not sure how to do this efficiently using stata. I have about
30 continuous variables. It seems that xi is limited to non
continuous variables and xi3 does not seem to work for 30 variables,
unless I am doing something wrong. I came up with a solution using
"foreach" to generate all the interactions terms and then try them in
a regression model:

The first problem I have is that this created duplicates (i.e.
var1Xvar2 is the same as var2Xvar1). Furthermore, I feel it is a
cumbersome way to do it, and I wonder if there is a more efficient way
to generate all possible pair interaction terms or better yet to have
an exploratory regression models testing all these pairs out and
selecting the best model. I saw someone someone doing something
similar very quickly in NCSS and I was hoping I could do the same in
STATA.

Thanks for your feedback.
Jean-Gael "JG" E. Collomb
PhD candidate

School of Natural Resources and Environment / School of Forest
Resources and Conservation