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

st: Dropping variables


From   "Pradeep Kurukulasuriya" <[email protected]>
To   <[email protected]>
Subject   st: Dropping variables
Date   Wed, 3 Nov 2004 22:42:17 -0500

I have  a large dataset with a lot of variables. I am trying to get rid of a
subset of the variables subject to a IF condition. I thought of  doing this
in a loop such as the following:

foreach var of varlist soils*{
sum `var'
drop `var' if r(mean)==0
}

However, the above doesn't work because stata doesn't like line 3. Is there
a way around this or another way to get rid of particular variables subject
to an IF condition?

Thanks
Pradeep



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