Sorry to bother you again - actually, I noticed a slight problem that
I should have should have mentioned in the previous mail. Your code
correctly drops a run of "not emp", however, I wish to keep "not emp"
if it preceded by "emp" in the previous wave as I am interested in
transitions for spell analysis. In eg below, I do not want to drop
ID=9 and wave=5 :
ID WAVE empstat drop
------------- ---- -----------
7 2 not emp 1
7 3 not emp 1
7 4 not emp 1
7 5 not emp 1
7 6 not emp 1
7 7 not emp 1
7 8 not emp 1
7 9 not emp 1
7 10 not emp 1
7 11 not emp 1
9 2 emp 0
9 3 emp 0
9 4 emp 0
9 5 not emp 1
On 3/29/07, sara khan <[email protected]> wrote:
Many thanks to you and Sergiy. This is what I needed.
On 3/29/07, David Kantor <[email protected]> wrote:
> At 08:53 AM 3/29/2007, Sara Khan wrote:
> >Dear Statalisters
> >
> >I wish to delete all records for a subset of individuals who are first
> >observed as not employed and keep those who are first observed as
> >employed. Thus, in the example, below, I want to retain those with
> >ID=2, 3, and 4 but delete ID 1, 5, 6, and 7. I am not sure how to do
> >this and would be grateful for your help.
> >
> >Sara
> >
> >
> >
> >ID WAVE empstat
> >------------- ---- -----------
> >1 1 not emp
> >------------- ---- -----------
> >2 2 emp
> >2 3 not emp
> >------------- ---- -----------
> >3 2 emp
> >3 3 not emp
> >------------- ---- -----------
> >4 2 emp
> >4 3 not emp
> >------------- ---- -----------
> >5 10 not emp
> >5 11 not emp
> >------------- ---- -----------
> >6 7 not emp
> >6 8 not emp
> >------------- ---- -----------
> >7 2 not emp
> >7 3 not emp
> >7 4 not emp
> >7 5 not emp
> >7 6 not emp
> >7 7 not emp
> >7 8 not emp
> >7 9 not emp
> >7 10 not emp
> >7 11 not emp
>
> Try this:
> bysort ID (WAVE): drop if empstat[1] == "not emp"
>
> HTH
> --David
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/