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   Joseph McDonnell <[email protected]>
To   [email protected]
Subject   Re: st: tagging observations where either x or y are true
Date   Mon, 26 Oct 2009 09:51:47 +0930

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

Cheers

Joseph

On Mon, Oct 26, 2009 at 7:38 AM, Michael McCulloch
<[email protected]> wrote:
> 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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index