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

st: RE: ghost value label problem


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: ghost value label problem
Date   Wed, 29 Oct 2003 18:11:24 -0000

This rang a bell. A while back the problem was described in very
similar
terms:

========================
Suppose you define value labels, attach them to variables, and then
later change your mind about attaching labels.

Even if you -drop- the value labels, according to Stata, for example
the
-describe- or -codebook- commands, the variables continue to have
labels
attached: it is just that those labels do not exist.

Labels can be detached from varname by

. label values varname

-labdtch- makes it easy to do this with a varlist.

-labdtch- does not drop value labels. For that, use -label drop-.

-labdtch- ignores any string variables in varlist.

Examples
--------

    . labdtch foreign

    The following detaches all value labels from variables (possibly
    useful, but also dangerous):

    . labdtch _all

=======================

-labdtch- is in a rag-bag of label utilities called -labutil-
on SSC.

. ssc desc labutil
. ssc inst labutil

Nick
[email protected]

Having said that, a -foreach- loop does the
same thing:

foreach v of var * {
	cap label val `v'
}

Dimitriy V. Masterov

> This is not a Halloween pranl. I am actually having a
> problem with ghost
> value labels. I am not sure whence the problem arises, so I
> will start at
> the beginning:
>
> 1) I converted a dataset from SPSS to Stata
> 2) I dropped all of the value labels using "label drop
> _all". "label list"
> showed that there are no value labels.
> 3) I cleaned the data and labeled SOME of the values myself.
> 4) Some of the numeric variables that had a value label
> before I dropped
> them, still "have" them. For example, "codebook leved27" yields
>
> ------------------------------------------------------------
> ------------------------------------------------------------
> ------------------------------------------------------------
> --------------------
> leved27
> Highest Level of Education Completed (Self-Report)
> ------------------------------------------------------------
> ------------------------------------------------------------
> ------------------------------------------------------------
> --------------------
>
>                   type:  numeric (byte)
>                  label:  V3078, but label does not exist
>
>                  range:  [1,99]                       units:  1
>          unique values:  12                       missing .:  6/123
>
>                   mean:   5.91453
>               std. dev:   9.32976
>
>            percentiles:        10%       25%       50%
>  75%       90%
>                                  2         2         3
>    9        10
> ------------------------------------------------------------
> ----------------------
>
>
>
> "des leved27" yields
>
>               storage  display     value
> variable name   type   format      label      variable label
> ------------------------------------------------------------
> -------------------
> leved27         byte   %9.0g       V3078      Highest Level
> of Education
>                                                 Completed
> (Self-Report)
>
> However, V3078 does not exist, and not all variables are
> effected. When I
> attempt to drop the label by hand, Stata gives me an error
> message saying
> that it does not exist. In my analysis, I segregate the
> variables based on
> whether they have value labels (other then yesno) or not,
> and it would be
> helpful if I could do this. This also makes me worried that
> there are some
> deeper problems that are not merely inconvenient.

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