Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Dropping variables conditionally


From   Friedrich Huebler <[email protected]>
To   [email protected]
Subject   st: Re: Dropping variables conditionally
Date   Wed, 13 Apr 2005 20:23:29 -0700 (PDT)

Ian,

You can use -dropmiss-.

. findit dropmiss

Friedrich Huebler

--- Ian Watson <[email protected]> wrote:
>   My particular task is to eliminate all variables from the dataset
>   which are empty, that is, have no observations. The following bit
>   of code has done this, but surely there is a simpler way which I
>   have overlooked?
> 
> local droplist "drop "
> foreach v of varlist * {
>     qui count if !mi(`v')
>     if r(N) == 0 local droplist "`droplist' `v'" 
> }
> `droplist'
> 
> 
> -- 
> Kind regards, 
> Ian
> 
> -------------------------------
> Ian Watson
> Senior Researcher
> acirrt, University of Sydney
> NSW, 2006, Australia
> 
> phone: 02 9351 5622
> email:[email protected]
> www.acirrt.com
> -------------------------------


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 
*
*   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