Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: loop over local list

From   "Radu Ban" <[email protected]>
To   <[email protected]>
Subject   st: loop over local list
Date   Tue, 13 Aug 2002 12:53:10 -0400

Dear all,

What is wrong with this piece of code (which gives an 'invalid syntax'

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.

thanks in advance,

Radu Ban

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index