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]

st: AW: drop observations after first occurence of an event


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: drop observations after first occurence of an event
Date   Fri, 19 Feb 2010 14:23:58 +0100

<> 



*************
clear*

inp byte(id event)
1 0
1 0
1 0
1 1
1 0
1 0 
2 0
2 0
2 1
2 1 
2 0 
3 0
3 1
3 0 
3 1 
end

list, noo

bys id: drop if sum(event[_n-1])>=1
list, noo
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von raoul reulen
Gesendet: Freitag, 19. Februar 2010 14:17
An: statalist@hsphsun2.harvard.edu
Betreff: st: drop observations after first occurence of an event

Dear All

Apologies for the probably straightforward query, but I cannot get it
done. I want to drop any observations after the first occurrence of an
event (coded as 1)  in my dataset. I am not interested in what happens
after the event, so want to drop any subsequent observations whether
they are events or not. See example below. For id nr 1 I want to drop
all observation after the first occurence of the number "1".

id event
1 0
1 0
1 0
1 1
1 0  <--drop
1 0 <--drop
2 0
2 0
2 1
2 1 <--drop
2 0 <--drop
3 0
3 1
3 0 <--drop
3 1 <--drop

Many thanks.

Raoul
*
*   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/


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