Cathy L. Antonakos wrote:
This question relates to the use of multiple variable lists (parallel
lists).
I have a dataset with many physiologic measures collected at two time
points.
There are three grouping variables (gp1, gp2, gp3).
[redacted]
I can use -foreach- to call each group variable separately, saving some
time, as follows:
local gp "gp1 gp2 gp3"
foreach var of varlist `gp' {
anova bt at `var'
anova btx atx `var'
anova btz atz `var'
}
But I'd like to figure out a way to call the lists of variables to reduce
the number of anova commands, something like:
anova `var2' `var1' `gp', cont(`var1')
Is there a way to do that?
--------------------------------------------------------------------------------
You mention parallel lists at first, but what you ask for looks more
like nested loops. You can loop over pretest-posttest variables and
grouping variables in a nested structure as follows:
foreach response of varlist b* {
local baseline = subinstr("`response'", "b", "a", 1)
foreach groupvar of varlist gp* {
anova `response' `baseline' `groupvar', continuous(`baseline')
}
}
This assumes that all variables in your dataset beginning with "b" are
response variables with a corresponding baseline that is named identically
with the exception of the first letter, which is "a". Note that there's
also a macro extended function for the string substitution. -help
extended_fcn- and scroll down to the section titled, "Macro extended
functions for parsing".
For parallel lists, see the FAQ "How do I process parallel lists?" at
http://www.stata.com/support/faqs/lang/parallel.html .
Joseph Coveney
P.S. I assume that you're aware of Roger Newson's -smileplot-
and -multproc-. -findit smileplot- if not.
P.P.S. You might be able to gain some efficiency with -sureg-.
*
* 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/