Statalist The Stata Listserver


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

Re: st: Dropping Subset of Variables


From   "Neil Shephard" <[email protected]>
To   [email protected]
Subject   Re: st: Dropping Subset of Variables
Date   Thu, 29 Mar 2007 13:50:36 +0100

Unless you are hitting memory issues in Stata there's no real
advantage to dropping out variables (although I guess you may be
preparing data to pass on to someone else).

So onto the problem, and hopefully a solution (although it may not be
very elegant).

You've a set of variables all beginning with 'hv' and ending with
_02..._46 that you wish to drop.

One possible option might be to -reshape- your data and then -drop-
variables and then observations -if()- a condition is met, but that's
likely to take some time given the number of variables your
indicating.

One solution might be to use two loops...

forval x = 2/9{
 drop hv*_0`x'
}
forval x = 10/46{
 drop hv*_`x'
}

(NB - My previous suggestion had invalid syntax because I had used
'in' which is used with -foreach- which is what I get for typing too
quickly and not re-reading my post before sending it).

The above isn't elegant, but should drop out the variables that you
want to get rid of.

Neil

--
"Every great advance in natural knowledge has involved the absolute
rejection of authority."  - Thomas H. Huxley

Email - [email protected] / [email protected]
Website - http://slack.ser.man.ac.uk/
Photos - http://www.flickr.com/photos/slackline/
*
*   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