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 11:13:30 +0100

On 3/29/07, Gauri Khanna <[email protected]> wrote:

Unfortunately, the wild card does not help because I have other variables in
my data set that have _02, _03 etc. attached and which I may want to keep.
I want to try and get rid of these listed variabls only with the _02 to _46
suffix.
I don't see what your trying to do, to start with you are saying you
have other variables with _02..._46 that you want to keep, and then
you say you want to get rid of variables only with the _02..._46
suffix.  This seems contradictory to me.

You can use the wild-card * in the middle so if you have...
. des
hvidx_01
hvidx_02
hvidx_03
hvidx_04
hvidx_05
hvidx_06
hv101_01
hv101_02
hv101_03
hv101_04
hv101_05
hv101_06
hv102_01
hv102_02
hv102_03
hv102_04
hv102_05
hv102_06

and you wanted to get rid of the hvidx_02 to hvidx_06 but retain all
of the hv101* and hv102 variables then you could use something like..

forval x in 1/6{
 drop hvidx_0`x'
}

Could you provide a clearer example of what you want to achieve.

The output from -describe- which will list the variable names, and
then say which you want to remove from the dataset.

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