Hi

In the data below the ID's is sorted in Waves (years). The Retirement variable can take 3 values, 0,1 and 2. The Weekly_Hours variable can take any value. A respondent is NOT retired if he/she has answered 0 or if he/she has answered 2 along with Weekly_Hours>=20. The opposite means retired (that is Retirement=1 or Retirement=2 & Weekly_Hours<20). I want to drop all id's for a respondent if he went on retirement and back to work in the wavespan he was in the data.

So if a respondent over the course of the waves goes from:

- Retirement = 0 to Retirement = 1 to Retirement = 0
- Retirement = 0 to Retirement = 1 to Retirement = 2 & Weekly_Hours>=20
- Retirement = 0 to Retirement = 2 & Weekly_Hours<20 to Retirement = 0
- Retirement = 0 to Retirement = 2 & Weekly_Hours<20 to Retirement = 2 & Weekly_Hours>=20
- Retirement = 2 & Weekly_Hours>=20 to Retirement = 1 to Retirement = 0
- Retirement = 2 & Weekly_Hours>=20 to Retirement = 1 to Retirement = 2 & Weekly_Hours>=20
- Retirement = 2 & Weekly_Hours>=20 to Retirement = 2 & Weekly_Hours<20 to Retirement = 0
- Retirement = 2 & Weekly_Hours>=20 to Retirement = 2 & Weekly_Hours<20 to Retirement = 2 & Weekly_Hours>=2

ID where the above happens I want to drop the hold group with the same ID. Hope it make sense if not then please ask for more information.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(HHIDPN Waves Retirement Weekly_Hours)
    1010  1 0 40
    3010  1 0 40
    3010  2 0 40
    3010  3 2 32
    3010  4 2 30
    3010  5 2 24
    3010  6 2 32
    3010  7 2 32
    3010  8 1  0
    3010  9 1  0
    3010 10 1  0
10013010  1 0 45
10013010  3 0 40
10013010  4 0 20
10013010  5 1  0
10013010  6 1  0
10013010  7 1  0
10013010  8 1  0
10013010  9 1  0
10013010 10 1  0
10038010  1 0 55
10038010  2 0 50
10038010  3 0 50
10038010  4 0 40
10038010  5 0 40
10038010  6 2 30
10038010  7 0 30
10038010  8 2 20
10038010  9 2 20
10038010 10 2 10
10050010  1 0 35
10050010  2 0 35
10050010  3 0 35
10050010  4 0 35
10050010  5 0 35
10050010  6 0 35
10050010  7 0 35
10050010  8 0 35
10050010  9 0 35
10050010 10 0 35
10063010  1 0  0
10063010  3 0 20
10063010  7 1  0
10063010  8 1  0
10063010 10 1  0
10094010  1 0 30
10097010  1 0 45
10097010  2 1  0
10109020  1 0 30
10109030  1 0 72
10109030  3 0 48
10109030  4 2 20
10109030  5 2 15
10109030  6 2 20
10109030  7 2 20
10109030  8 2 20
10109030  9 2 20
10109030 10 2 30
10114010  1 0 35
10114010  2 1  0
10114010  3 1  0
10114010  5 1  0
10155010  1 0 40
10155010  2 0 40
10155010  3 0 40
10155010  4 0 40
10210010  1 0 30
10210010  2 0  0
10210010  3 0 40
10210010  4 0 20
10210010  5 0 20
10210010  8 1  0
10210020  1 0  0
10210020  2 1  0
10210020  3 0  0
10210020  4 0 40
10210020  6 0 40
10210020  7 2  0
10210020  8 1  0
10210020  9 1  0
10210020 10 1  0
10225010  1 0 37
10225010  2 0  0
10225010  3 1  0
10225010  5 1  0
10225010  6 2  0
10225010  7 2  0
10225010  8 1  0
10225010  9 1  0
10225010 10 1  0
10237020  1 0 40
10237030  1 0 35
10240010  1 0 40
10240010  2 2  0
10240010  6 1  0
10299010  1 0 40
10299010  2 0 40
10299010  4 0 55
10299010  5 0 45
10299010  6 2 10
end
Thank you very much