Dear Statalist,

I have a dataframe like:
householdno foodcount foodcode
1 1 67
1 2 65
1 3 875
2 1 65
2 2 344
2 3 367
3 1 67
3 2 54
4 1 76
4 2 98
4 3 76
..... ... ....
The enumerator forgot to input the foodcode 67 in some of the households, which are household number 5, 6, 7, 8, 9, 10, 49, 47, 104, 132, 133, 134, 135, 145. I tried to fix the issue by using the code:

Code:
insobs 14
replace foodcode=67 if missing(foodcode)

foreach i in 5 6 7 8 9 10 49 47 104 132 133 134 135 145 {
replace householdno=`i' if missing(householdno) & householdno!=`i'
}
But I received "invalid syntax" report.

Can you please tell me what goes wrong here?

Thank you so much in advance!