Hi. I am currently working with longitudinal data I have converted to panel data and I now need some help getting to the final sample.

So the respondents must have worked for at least ten years.

What my datasets contains is different cohorts. So HACOHORT describes which cohort the respondents belong to (2,3,4,5).

I need for the different cohorts to keep the respondents who is not retired when entering the survey. That is when Retirement==0. Furthermore a respondent is considered not retired if Retirement==2 together with Weekly_Hours>20

So first question is. In each cohort (HACOHORT[2,3,4,5]) how do I keep both the respondents which have Retirement==0 and the ones with Retirement==2 together with Weekly_Hours>20

Next question is more tricky I think. If a respondent enters not retired from the criterias above and then becomes retired (either by Retirement==2 together with Weeklyhours<20, or Retirement==1), and then enters the labor force (becoming not retired) again I want to exclude these individuals. So changing from not retired, to retired and back to nor retired over the time period which In this example is "Waves" which go from 1-10 where there is two years in between.

In the dataex I have attached the only command I have done is to drop for missing observation on "Retirement". I hop the question make sense, if not please say so and I will try to elaborate.

Thank you very much