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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Keep specific observation


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Keep specific observation
Date   Fri, 2 Sep 2011 15:17:07 +0100

bysort col1 (col2) : keep if col2 == _n & _N == 3

Nick

On Fri, Sep 2, 2011 at 3:12 PM, Yun <yuniphone@yahoo.co.id> wrote:
> I need help in stata command to drop/keep certain observations using stata 11.0
>
>
> There are two column of different data. Fisrt column is A,B,C (unique ID). The second column has data 1,2,3.
>
> Column 1 Column2
> A                  1
> A                  2
> A                  3
> B                  1
> B                  2
> C                  1
> C                  2
> C                  3
> D                  1
> D                  3
>
>
> I need all the observations that satisfy this condition --> column 1 will have group of column 2 (1,2,3)--> for instance A & C.
>
> I do not know the command for this.
>

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