title: Dropping observations in Stata based on age and panel round
body: <p>I have a panel dataset and I want to drop those respondents that were aged 40 years and over in their first round of the survey.</p>
  
  <p>I tried doing<code>drop if age&gt;40</code> and also <code>drop if age&gt;40 &amp; t==1</code> where t is an identifier of the survey wave the person is in. However when I do the second I am left with people over the age of 40.</p>
  
  <p>Here is an example of how my data looks like:</p>
  
  <pre><code>pid      age     wave  year of survey
  1         20      1      2005
  1         21      2      2006
  1         22      3      2007 
  1         23      4      2008
  2         37      1      2006 
  2         38      2      2007  
  2         39      3      2008
  2         40      4      2009
  3         40      1      2008
  3         41      2      2009
  3         42      3      2010
  3         43      4      2011
  </code></pre>
  
  <p>My aim is not to lose the 3rd respondent given that he/she was within my target age group when they were first surveyed but they were not in the following survey years (rather than just being left with his/her first wave of data and dropping the other 3 that is what is being done if I simply do <code>drop if age&lt;=40</code>). </p>
  
  <p>Is there another way so as to be left with only people up to the age of 40 while keeping those who were 40 in their first wave even if they turn 41, 42 etc in subsequent waves? I basically want to constrain my panel into the up to 40 years of age group while keeping those who were 40 in their wave but might be over 40 in subsequent waves (I only have 4 waves).</p>