Hey folks. I have choice data that has the following structure:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(id choiceoccasion) str1 alt byte chosen
1 1 "A" 0
1 1 "B" 0
1 1 "C" 1
1 2 "A" 0
1 2 "B" 0
1 2 "C" 1
1 3 "A" 1
1 3 "B" 0
1 3 "C" 0
2 4 "A" 1
2 4 "B" 0
2 4 "C" 0
2 5 "A" 0
2 5 "B" 0
2 5 "C" 1
2 6 "A" 0
2 6 "B" 1
2 6 "C" 0
end
Each person (id) makes three choices (choiceoccasion) over three alternatives, A, B, and C. The variable "chosen" takes on the value of 1 if the person chose that alternative, and zero otherwise. I want to erase all choice occassions in which the person chose alternative "C" from my dataset. So, in the context of my example data, I want to erase choice occasions 1, 2, and 5. This is what I want the new dataset to look like:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(id choiceoccasion) str1 alt byte chosen
1 3 "A" 1
1 3 "B" 0
1 3 "C" 0
2 4 "A" 1
2 4 "B" 0
2 4 "C" 0
2 6 "A" 0
2 6 "B" 1
2 6 "C" 0
end
The best solution I could come up with is this:

forvalues i = 3(3)`=_N' {
if alt[`i'] =="C" & chosen[`i'] ==1 {
local x=`i'- 2
drop in `x'/`i'
}
}

However, I noticed that this only works when no two consecutive choice occasions choose "C".
Any advice on how to do this? It would be greatly appreciated!