Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Drop subjects from a panel


From   Ayman Farahat <ayman.farahat@yahoo.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Drop subjects from a panel
Date   Wed, 8 Feb 2012 15:10:54 -0800 (PST)

Thanks Phil and Klaus, 

Phil's suggestion worked. 

Best
Ayman




________________________________
From: Phil Clayton <philclayton@internode.on.net>
To: statalist@hsphsun2.harvard.edu 
Sent: Wednesday, February 8, 2012 2:08 PM
Subject: Re: st: Drop subjects from a panel

Yes, you're right - that would not remove other records for that subject.

Here's my suggestion:

gen byte todrop=covariate==0 & time==2
bysort subject (todrop): drop if todrop[_N]==1

The idea is that when sorting by -todrop- within subject, the last -todrop- per subject (todrop[_N]) tells you whether or not that subject had any records matching the exclusion criteria.

Phil

On 09/02/2012, at 8:28 AM, Ayman Farahat wrote:

> Thanks Klauss; 
> 
> One question : Wouldnt this just remove the observation at time==2 while leaving the observations at different times?
> Ayman
> 
> 
> 
> ----- Original Message -----
> From: Klaus Pforr <kpforr@googlemail.com>
> To: statalist@hsphsun2.harvard.edu
> Cc: 
> Sent: Wednesday, February 8, 2012 12:52 PM
> Subject: Re: st: Drop subjects from a panel
> 
> <>
> 
> Hello Ayman,
> 
> try
> <drop if covariate==0 & time==2>
> 
> best
> 
> Klaus
> 
> Am 08.02.2012 21:36, schrieb Ayman Farahat:
>> Hello ;
>> 
>>    I have a panel data. I would like to remove all subjects that had a certain co-variate at a specific time.
>> 
>> For example, drop all subjects that had a covariate==0 for time==2.
>> Any help greatly appreciated.
>> 
>> Thanks
>> Ayman
>> 
>> 
>> *
>> *   For searches and help try:
>> *  http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
> 
> 
> -- 
> __________________________________
> 
> Klaus Pforr
> MZES AB - A
> Universität Mannheim
> D - 68131 Mannheim
> Tel:  +49-621-181 2797
> fax:  +49-621-181 2803
> URL:  http://www.mzes.uni-mannheim.de
> 
> Besucheranschrift: A5, Raum A309
> __________________________________
> 
> *
> *   For searches and help try:
> *  http://www.stata.com/help.cgi?search
> *  http://www.stata.com/support/statalist/faq
> *  http://www.ats.ucla.edu/stat/stata/
> 
> 
> *
> *   For searches and help try:
> *  http://www.stata.com/help.cgi?search
> *  http://www.stata.com/support/statalist/faq
> *  http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index