Statalist


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

RE: st: tagging observations where either x or y are true


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: tagging observations where either x or y are true
Date   Mon, 26 Oct 2009 11:41:26 -0000

I would recommend against using numbers with fractional parts as
identifiers, if only because of the precision issues highlighted in a
concurrent thread (and every month on this list). 

Nick 
n.j.cox@durham.ac.uk 

Michael McCulloch

Brilliantly efficient! Thanks!
Michael

On Oct 25, 2009, at 5:21 PM, Joseph McDonnell wrote:

> input sampleid x y
>        30.1         0      1
>        34.1         1      0
>        34.1         0      1
>        34.3         1      0
> end
> collapse (max) x y, by(sampleid)
> list
>
>
>     +------------------+
>     | sampleid   x   y |
>     |------------------|
>  1. |     30.1   0   1 |
>  2. |     34.1   1   1 |
>  3. |     34.3   1   0 |
>     +------------------+
>
> On Mon, Oct 26, 2009 at 7:38 AM, Michael McCulloch

>> 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.

*
*   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   |   What's new   |   Site index