Hello everyone,
I'm fairly new to STATA but this one issue has been driving me crazy...I would really appreciate any help...
I'm trying to loop through a set of variables, and any variables that have a certain value will execute a series of if statements afterwards...however the if statement which determines if the value is met doesn't seem to be being read, or the program isn't entering that bracket for some reason. I've tested this by having a number (varno) displayed before and after the if statement in question...before it will work but after it won't. informant_type1-7 is a numeric variable with values 0-4
gen varno = 1
foreach informant of varlist informant_type1 informant_type2 informant_type3 informant_type4 informant_type5 informant_type6 informant_type7 {
di varno
if `informant' == 4 {
di varno
commands...
}
}
Is there something wrong with the way I am setting this up?
Many thanks for any advice!
I'm fairly new to STATA but this one issue has been driving me crazy...I would really appreciate any help...
I'm trying to loop through a set of variables, and any variables that have a certain value will execute a series of if statements afterwards...however the if statement which determines if the value is met doesn't seem to be being read, or the program isn't entering that bracket for some reason. I've tested this by having a number (varno) displayed before and after the if statement in question...before it will work but after it won't. informant_type1-7 is a numeric variable with values 0-4
gen varno = 1
foreach informant of varlist informant_type1 informant_type2 informant_type3 informant_type4 informant_type5 informant_type6 informant_type7 {
di varno
if `informant' == 4 {
di varno
commands...
}
}
Is there something wrong with the way I am setting this up?
Many thanks for any advice!
Comment