Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Deleting a cohort


From   "sara khan" <[email protected]>
To   [email protected]
Subject   Re: st: Deleting a cohort
Date   Thu, 29 Mar 2007 14:28:35 +0100

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index