Apologies if this is very rudimentary but what my Googling could uncover I didn't really understand.
Here's a semi-minimal example of what I'm trying to do with two indices:
foreach (i j) in (first 0) (second 1) {
gen `i'=1 if prov==`j'&!missing(age)
recode `i' .=0
gen `i'm=1 if `i'==1&M==1
recode `i'm .=0
gen `i'f=1 if `i'==1&F==1
recode `i'f .=0
}
I'd like i to be first and j to be 0 for one iteration, for the second iteration, I'd like i to be second while j is 1.
Here's a semi-minimal example of what I'm trying to do with two indices:
foreach (i j) in (first 0) (second 1) {
gen `i'=1 if prov==`j'&!missing(age)
recode `i' .=0
gen `i'm=1 if `i'==1&M==1
recode `i'm .=0
gen `i'f=1 if `i'==1&F==1
recode `i'f .=0
}
I'd like i to be first and j to be 0 for one iteration, for the second iteration, I'd like i to be second while j is 1.
Comment