|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: RE: two STATA questions
From
"Ni Frank" <[email protected]>
To
[email protected]
Subject
RE: st: RE: two STATA questions
Date
Wed, 28 Feb 2007 02:15:56 -0500
Got it. You are right. I was thinking about the second quetion which keeps
those observations at least one of variables is zero.
Thanks again!
Frank
From: "Nick Cox" <[email protected]>
Reply-To: [email protected]
To: <[email protected]>
Subject: RE: st: RE: two STATA questions
Date: Tue, 27 Feb 2007 09:49:33 -0000
Wrong. -drop if count- is equivalent to -drop if count != 0- which in this
case would only arise -if count > 0-.
Besides, you asked for -drop-ping or -keep-ing if and only if at least
one variable were zero. The variable -count- is a count of the number
of variables in which values are zero in each observation. So,
drop if count == 0
would -drop- only those observations in which no values were zero.
There is more on constructs like -if count- in
FAQ . . . . . . . . . . . . . . . . . . . . . . . True and false in
Stata
_________________________________________________________________ 2/03 What is true and false in Stata?
http://www.stata.com/support/faqs/data/trueorfalse.html
Nick
[email protected]
Ni Frank
> Oh,I see. By the way, the "drop if count" should be "drop
> if count==0",
> right? I have tried your method. It works. Thanks very much!
Nick Cox
> > > 1) There are 50 varialbes, w05100, w05200,....,w10000. We
> > > want to DROP
> > > those obversations for which at least one of the above
> > > variables takes
> > > value of 0. When I use "drop if w*==0, it said "W* invalid name".
> > > Does anybody know what's wrong?
> >
> >That's illegal. You can't put a wildcard there after -if-.
> An expression
> >can go there, but a wildcard doesn't qualify as an expression.
> >
> >Here is one way to do it.
> >
> >gen byte count = 0
> >
> >qui forval i = 5100(100)10000 {
> > replace count = count + (w0`v' == 0)
> >}
> >
> >drop if count
> >
> > > 2) Now, if we want to KEEP those obersvations for which
> at least one
> > > of the variables w05100, w05200, ....,w09900 takes value
> of 0. How to
> > > do that?
> >
> >It's the same story, except for -keep- instead of -drop-.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
�����������ѽ��н�������ʹ�� Live Messenger;
http://get.live.com/messenger/overview
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* 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 |