Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: how drop a block of cases based other variable values
From
Maarten Buis <[email protected]>
To
[email protected]
Subject
Re: st: how drop a block of cases based other variable values
Date
Fri, 9 Dec 2011 14:53:21 +0100
On Fri, Dec 9, 2011 at 2:45 PM, Daniel Marcelino wrote:
> can anyone point me how can I drop all observations belonging to
> "r" based on "winner" value? I meant, I don't wish to drop only
> observations where winner values is 1, but
> given I got a winner in "r==a" I want drop all observations of this group.
*------------ begin example --------------
clear
input str2 r byte(w v1 v2 winner)
"a" .5 1 2 .
"a" .1 2 3 .
"a" .9 3 2 1
"a" .9 3 4 1
"a" .2 4 5 .
"a" .3 5 1 .
"b" .4 1 2 .
"b" .1 2 3 .
"b" .7 3 4 .
"b" .8 4 1 .
"b" .8 4 5 .
"b" .9 5 1 .
end
bys r : egen byte todrop = total(winner)
drop if todrop
drop todrop
*------------- end example --------------------
hope this helps,
Maarten
--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany
http://www.maartenbuis.nl
--------------------------
*
* 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/