Dear all,
Been learning so much from this forum and finally have my own inquire to share.
My objective is to select (use -keep- or -drop- or whatever works) a subset of data that: 1) find==1 and there is no duplicates according to id (like observation no.5 with id==3) ; 2)find ==1 and there are duplicates according to id, then I want to keep that "group" (like the obs with id==1, they have find==0 | find==1, but as long as one id==1 have id==1 I need to keep all the obs with id==1. Same goes for obs with id==4). I want to drop id==2| id==5 | id==6 |id==7|id==8 because obs with these ids are either single and with find ==0 or have dups but none in the id group have find==1.
So I hope there is something that can help me keep ob no.1-3, 5-7 and dump the others. I know this may sound unnecessarily complicated but hopefully there is a way. Thanks!
Best,
Ginny
Been learning so much from this forum and finally have my own inquire to share.
My objective is to select (use -keep- or -drop- or whatever works) a subset of data that: 1) find==1 and there is no duplicates according to id (like observation no.5 with id==3) ; 2)find ==1 and there are duplicates according to id, then I want to keep that "group" (like the obs with id==1, they have find==0 | find==1, but as long as one id==1 have id==1 I need to keep all the obs with id==1. Same goes for obs with id==4). I want to drop id==2| id==5 | id==6 |id==7|id==8 because obs with these ids are either single and with find ==0 or have dups but none in the id group have find==1.
So I hope there is something that can help me keep ob no.1-3, 5-7 and dump the others. I know this may sound unnecessarily complicated but hopefully there is a way. Thanks!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(find id) 0 1 1 1 1 1 0 2 1 3 1 4 0 4 0 4 0 5 0 6 0 7 0 8 0 8 end
Ginny
Comment