Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Variable names and labels for interaction terms
From
"Nic" <[email protected]>
To
<[email protected]>
Subject
st: Variable names and labels for interaction terms
Date
Tue, 22 Mar 2011 21:23:12 -0400
Hello all,
I've figured out how to create all my (continuous x continuous) interaction
variables at once but I'm trying to learn how to (1) automatically create
variable labels for them, and (2) name the new variables based on truncated
versions of the component variables' names.
Here is what I have so far:
foreach x of varlist s* {
foreach y of varlist f* {
generate i`x'_x_`y' =`x'*`y'
}
}
(1) I'd like each interaction term's variable label to be comprised of the
component variables' labels. For example, a label that reads, "Physical
Abuse x Self-Esteem".
I'm guessing this is possible since I can apply a single original variable
label using the tips found here:
http://www.stata.com/support/faqs/data/variables.html
But I'm having trouble figuring out how to do something similar in the more
complex scenario when two variables are involved. Any hints?
(2) I'd also like the interaction term variable names to be based on
truncated versions of the component variables' names. For example, "is1f1"
would be an ideal name for an interaction term created from
"s1PhysicalAbuse" and "f1SelfEsteem". Currently my code creates variable
names that are quite lengthy, for example,
"is1PhysicalAbuse_x_f1SelfEsteem". It would save a lot of typing in later
analyses if I were able to refer to a particular interaction by typing just
the prefixes for the predictor and moderator variables. Again, any hints?
With thanks,
Nic
*
* 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/