Be very careful here. As numerous threads bear
witness, looping around
local testsum = "`testsum'+`var'"
will truncate your macro at some limit. It
is much safer to copy, not evaluate:
local testsum "`testsum'+`var'"
Nick
[email protected]
Michael S. Hanson
> Answering my own question (after tearing out some more
> hair first),
> the following -- ultimately quite simple -- code seems to do
> the trick.
> Improvements or alternatives are welcome.
>
> . local testsum "0"
> . foreach var of varlist x* {
> . local testsum = "`testsum'+`var'"
> . }
> . test `testsum' = 0
>
*
* 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/