| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Dropping Subset of Variables
Dear Neil,
I will try out your command that you sent.
As an explanation (and sorry for not being clear): I use the -describe-
command below. As you see, I have a bunch of variables (I have copied a
subset from my data set as an example ). I am interested in getting rid of
variables with _02 to _46 in the first set with hv* characters (hence
hvidx_02, h101_02 etc . uptil _46). I also have more variables (also shown
below) that share the same suffix _01,_02 .... which I woud like to keep.
Hence, my question is how can I get rid of the variabeles with hv*_02 to
hv*_46.
hvidx_01 byte %8.0g line number
hv101_01 byte %8.0g hv101_01 relationship to head
hv102_01 byte %8.0g hv102_01 usual resident
hv103_01 byte %8.0g hv103_01 slept last night
hv104_01 byte %8.0g hv104_01 sex of household member
hv105_01 byte %8.0g hv105_01 age of household members
hv106_01 byte %8.0g hv106_01 highest educational level
hv107_01 byte %8.0g hv107_01 highest year of education
hv108_01 byte %8.0g hv108_01 education in single years
hv109_01 byte %8.0g hv109_01 educational attainment
hv110_01 byte %8.0g hv110_01 member still in school
hv115_01 byte %8.0g hv115_01 current marital status
hv116_01 byte %8.0g hv116_01 currently, formerly, never m.
hv117_01 byte %8.0g hv117_01 eligibility for female intview
hvidx_02 byte %8.0g line number
hv101_02 byte %8.0g hv101_02 relationship to head
hv102_02 byte %8.0g hv102_02 usual resident
hv103_02 byte %8.0g hv103_02 slept last night
hv104_02 byte %8.0g hv104_02 sex of household member
hv105_02 byte %8.0g hv105_02 age of household members
hv106_02 byte %8.0g hv106_02 highest educational level
hv107_02 byte %8.0g hv107_02 highest year of education
hv108_02 byte %8.0g hv108_02 education in single years
hv109_02 byte %8.0g hv109_02 educational attainment
hv110_02 byte %8.0g hv110_02 member still in school
hv115_02 byte %8.0g hv115_02 current marital status
hv116_02 byte %8.0g hv116_02 currently, formerly, never m.
hv117_02 byte %8.0g hv117_02 eligibility for female intview
hvidx_03 byte %8.0g line number
hv101_03 byte %8.0g hv101_03 relationship to head
hv102_03 byte %8.0g hv102_03 usual resident
hv103_03 byte %8.0g hv103_03 slept last night
hv104_03 byte %8.0g hv104_03 sex of household member
hv105_03 byte %8.0g hv105_03 age of household members
hv106_03 byte %8.0g hv106_03 highest educational level
hv107_03 byte %8.0g hv107_03 highest year of education
hv108_03 byte %8.0g hv108_03 education in single years
hv109_03 byte %8.0g hv109_03 educational attainment
hv110_03 byte %8.0g hv110_03 member still in school
hv115_03 byte %8.0g hv115_03 current marital status
hv116_03 byte %8.0g hv116_03 currently, formerly, never m.
.
..
....
idxh4_01 byte %8.0g index to household schedule
sh09_01 byte %8.0g sh09_01 marital status
sh11_01 byte %8.0g sh11_01 can read and write
sh12_01 byte %8.0g sh12_01 ever been to school
sh13_01 byte %8.0g sh13_01 main reason never went to
school
sh14_01 byte %8.0g highest grade
sh16_01 byte %8.0g sh16_01 main reason not going to
school
sh17_01 byte %8.0g sh17_01 occupation
sh18_01 byte %8.0g sh18_01 work for salary
sh24_01 byte %8.0g sh24_01 chew tobacco
sh25_01 byte %8.0g sh25_01 drink alcohol
sh26_01 byte %8.0g sh26_01 smoke
sh27_01 byte %8.0g sh27_01 smoked regularly
shed4_01 byte %8.0g shed4_01 education
shed6_01 byte %8.0g shed6_01 education
shage_01 byte %8.0g age of hh members or from
woman's questionnaire
idxh4_02 byte %8.0g index to household schedule
sh09_02 byte %8.0g sh09_02 marital status
sh11_02 byte %8.0g sh11_02 can read and write
sh12_02 byte %8.0g sh12_02 ever been to school
sh13_02 byte %8.0g sh13_02 main reason never went to
school
sh14_02 byte %8.0g highest grade
sh16_02 byte %8.0g sh16_02 main reason not going to
school
sh17_02 byte %8.0g sh17_02 occupation
sh18_02 byte %8.0g sh18_02 work for salary
sh24_02 byte %8.0g sh24_02 chew tobacco
sh25_02 byte %8.0g sh25_02 drink alcohol
sh26_02 byte %8.0g sh26_02 smoke
sh27_02 byte %8.0g sh27_02 smoked regularly
Regards,
Gauri
From: "Neil Shephard" <[email protected]>
Reply-To: [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/
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
*
* 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/