Statalist


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

Re: st: drop redundant value labels


From   Ronnie Babigumira <[email protected]>
To   [email protected]
Subject   Re: st: drop redundant value labels
Date   Fri, 15 Feb 2008 16:19:12 +0100

Thanks Maarten and Austin.

Ronnie Babigumira wrote:
I am merging a number of datasets. Each of the categorical variables in these datasets has value labels, however, what I would like to do is to only retain the value labels for the variables that end up in any given merged dataset.

As an example,

I merge two files, and keep four variables

Contains data from sec3.dta
obs: 9,946
vars: 4 14 Feb 2008 13:49
size: 159,136 (99.8% of memory free)
-------------------------------------------------------------------------------
storage display value
variable name type format label variable label
-------------------------------------------------------------------------------
hhid str9 %9s
literacy byte %29.0g litlbl Literacy Status
apprentice byte %35.0g applbl Apprentice-ship
training byte %29.0g trnlbl Training
-------------------------------------------------------------------------------
Sorted by:
Note: dataset has changed since last saved

However, this dataset retains labels from the parent datasets
. label dir
occlbl
indlbl
sexlbl
worklbl
pjoblbl
peduclbl
edlbl
marlbl
relalbl
litlbl
applbl
trnlbl

What I would like to do is keep only litlbl applbl trnlbl. Obviously, I could simply -label drop- the ones I am not interested in but I was hoping for a generalized solution that does not require me to type all the ones that are dropped (I am working with many tables).

My thoughts (with no idea how to make them happen)
1. Save the names of all the variables in the final data set (something like `r(varlist)' from -describe-)
2. Create a local macro called tokeep which is `r(varlist)' less variables that do not have value labels
3. Drop every value label that is in not in `tokeep'

I would appreciate any help

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

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