On May 24, 2006, at 11:59 AM, Thomas wrote:
using the foreach command I would like to exclude certain
variables, e.g:
"foreach var of varlist _all [/excluding a, b, c/]".
Is that possible and if so how?
For maximum readability, I'd suggest the following:
unab allvars: _all
loc vars_to_exclude "a b c"
loc pruned_list : list allvars - vars_to_exclude
foreach var of loc pruned_list {
...
}
or, if you're counting lines, just
unab allvars: _all
loc vars_to_exclude "a b c"
foreach var in `:list allvars - vars_to_exclude' {
...
}
-- Phil
*
* 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/