Statalist


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

Re: st: Drop variables satisfying a condition


From   n j cox <n.j.cox@durham.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Drop variables satisfying a condition
Date   Mon, 16 Jul 2007 19:58:46 +0100

There were several answers to this. I agree closely with Maarten Buis
and Austin Nichols, whose basic approach was to cycle over a varlist,
-count- observations satisfying the specified condition for each variable and then to -drop- the variable in question if all observations
satisfied the condition. My reasons for posting are just to

* add a literature reference in which this approach is applied to
_exactly_ the example problem (and others).

Cox, N.J. 2007. Making it count. Stata Journal 7(1): 117-130.

* mention -dropmiss- (-search dropmiss-), which could be used
for the example problem once zeros had been replaced by missing.

Nick
n.j.cox@durham.ac.uk

Guillermo Villa (edited)

I wonder whether it is possible to -drop- several variables in a dataset
specifying an -if- condition. For instance, it would be interesting
being able to -drop- all variables in the dataset for which all cases
are 0 or missing values. I have been reading the help documentation on
the -drop- command, however I am unable to find the right answer so
far. Note that I want to drop variables and not cases.

*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index