[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Austin Nichols" <austinnichols@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Drop variables satisfying a condition |

Date |
Fri, 6 Jul 2007 13:03:19 -0400 |

David Kantor et al.: I agree that testing sum=0 is inappropriate, and there is no need to invoke -summarize- and all its machinery when -count- will do; but I think David Kantor does not mean capture confirm `var' == 0 but rather capture assert `var' == 0 as the first will always fail. Given that Maarten and I have both posted programs to handle the string variables, David Elliot's program need not be fixed, I think. On 7/6/07, David Kantor <kantor.d@att.net> wrote:

David Elliot wrote in response to the question from Guillermo Villa: [...] > quietly summarize `var' > if `r(sum)' == 0 { // r(sum) is returned by summarize > drop `var' > display as txt "Dropping " as result "`var'" > } [...] I don't think that testing `r(sum)' == 0 is appropriate. This indicates that the sum of the values is 0. I think you really want to test whether all the values are 0. And it's easy to construct an example where the sum is 0 but not all values are 0. I would suggest... capture confirm `var' == 0 if ~_rc { drop `var' } Another thing you may want to test is whether r(sd) ==0 after a -summarize-, which tells you that the values are constant. Also note that the quotes around r(sum) were unnecessary, though that is a moot point. HTH --David

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

**Follow-Ups**:**Re: st: Drop variables satisfying a condition***From:*"David Elliott" <dcelliott@gmail.com>

**Re: st: Drop variables satisfying a condition***From:*David Kantor <kantor.d@att.net>

**References**:**st: Drop variables satisfying a condition***From:*"Guillermo Villa" <guillermo@baphealth.com>

**Re: st: Drop variables satisfying a condition***From:*"David Elliott" <dcelliott@gmail.com>

**Re: st: Drop variables satisfying a condition***From:*David Kantor <kantor.d@att.net>

- Prev by Date:
**st: Estimating a hazard model with grouped data** - Next by Date:
**Re: st: hetereoskedasticity/serial correlation with RE xtprobit xttobit?** - Previous by thread:
**Re: st: Drop variables satisfying a condition** - Next by thread:
**Re: st: Drop variables satisfying a condition** - Index(es):

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