Dear fellow Stata users,
I've got a question about the 'continue' command. This is my dataset:
I have got a list of observation identifyers in the variable 'identifyer'. I created a loop for these observations which only needs to run if a certain equality is not met, therefore I created this code:
foreach identifyer in identifyer {
if `observationyear' == `firstyear' {
continue
}
...
}
This should thus only run for identifyer 2-5. I tried some different things, but even without the 'if and continue' command the loop only runs one time (only for identifyer 1). What could be the cause that the loop only runs 1 time (so only for observation identifyer[1])?
This also runs only one time:
foreach id in identifyer {
disp `id'
}
Result:
1
.
Kind regards,
Remon
I've got a question about the 'continue' command. This is my dataset:
identifyer | observationyear | firstyear |
1 | 1990 | 1990 |
2 | 1991 | 1990 |
3 | 1991 | 1990 |
4 | 1993 | 1990 |
5 | 1994 | 1990 |
6 | 1995 | 1990 |
foreach identifyer in identifyer {
if `observationyear' == `firstyear' {
continue
}
...
}
This should thus only run for identifyer 2-5. I tried some different things, but even without the 'if and continue' command the loop only runs one time (only for identifyer 1). What could be the cause that the loop only runs 1 time (so only for observation identifyer[1])?
This also runs only one time:
foreach id in identifyer {
disp `id'
}
Result:
1
.
Kind regards,
Remon
Comment