Juanita is almost right. However, the alternative
is no alternative. The whole point about -of- is
that it signals to -foreach- that some smartness
will be needed: in this example, to treat the
varlist as such. -in- by contrast signals that
what follows is to be taken literally. The loop
will choke on
p03a01a-p03a01m
which will _not_ be expanded as desired. It
will be treated -- in context -- as if it were
a single varname, which it is not.
Nick
[email protected]
Riano, Juanita
> I think the problem with the varlist is that you need to use "of"
> instead of "in" :
>
> Replace:
> foreach var in varlist p03a01 p03a01a-p03a01m
>
> With:
> foreach var of varlist p03a01 p03a01a-p03a01m
>
> Or alternatively use
>
> foreach x in p03a01 p03a01a-p03a01m
*
* 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/