<> 
*************
clear*
inp sampleid byte(x y)
         30.1         0      1
         34.1         1      0
         34.1         0      1
         34.3         1      0
end
compress
list, noobs  
bys sampleid:egen maxx=max(x)
by sampleid: egen maxy=max(y)
by sampleid: gen byte tag= /* 
*/ _N>1 & _n==_N &  /* 
*/ maxx==1 & maxy==1
replace x=maxx if tag
replace y=maxy if tag
by sampleid: drop if  /* 
*/ _n!=_N
drop maxx maxy tag
l, noo sepby(sampleid)
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Michael
McCulloch
Gesendet: Sonntag, 25. Oktober 2009 23:08
An: Statalist Statalist
Betreff: st: tagging observations where either x or y are true
I'd appreciate advice on this problem which although apparently simple  
is somewhat vexing.
Note that for:
	sample 30.1 only y is true,
	sample 34.3 only x is true,
but 	sample 34.1 both x and y are true,
     sampleid   x     y
         30.1         0      1
         34.1         1      0
         34.1         0      1
         34.3         1      0
What I'd like to achieve is only one entry for 34.1, where both x and  
y ==1.
I can identify 34.1 with -duplicates-, but can't figure out the next  
step of concatenating observations for that sampleid such that x=y=1.
Michael McCulloch
Pine Street Foundation
124 Pine Street
San Anselmo, CA 94960-2674
tel:	415-407-1357
fax: 	206-338-2391
[email protected]
*
*   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/