"Radu Ban" <[email protected]>
What is wrong with this piece of code (which gives an 'invalid syntax'
error)
local married "0 5"
local single "5 6"
foreach mstat in `mar' `sng'
tokenize `mstat'
...
keep if marstat > `1' & marstat <= `2'
the last line is the one that produces the error.
What I'm trying to do is make a loop, in which the first run keeps
values of
marstat 1 through 5, and the second run keeps value 6. Is there an
alternative solution? Note that marstat has values 0 to 6 where 0
stands for
'not available', 1-5 are for people who were at some point married and
6 for
people who were never married. I could recode it, but I'll lose
information
that I might need in the future.
>>> What you actually typed is not at all clear to me.
You define locals called -married- and -single-
and then loop over (other?) locals called -mar-
and -sng-?
Where are the braces { }?
It seems you want to do something for
two subsets of the data. It is not clear
why you need to drop the complementary
subset.
How about
... if inrange(marstat,1,5)
... if marstat == 6
Nick
[email protected]
*
* 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/