Statalist The Stata Listserver


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

RE: st: Label problem - fdasave


From   Fred Wolfe <fwolfe@arthritis-research.org>
To   statalist@hsphsun2.harvard.edu, <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Label problem - fdasave
Date   Thu, 07 Sep 2006 09:55:46 -0500

Thanks. Nick. Those are helpful points.

I guess one might complain weakly that Stata's behavior is inconsistent. If the label no longer exists tabulate doesn't complain but fdause fails. Perhaps fdause should issue a warning that the label don't exist rather than an error message.

Fred

At 09:38 AM 9/7/2006, Nick Cox wrote:

I suspect that Phil is exactly on the right lines.

From Stata's point of view, you attached a value label
to a variable, but you haven't, as far as Stata knows,
changed your mind about that.

The fact that the label no longer exists is quite
separate. For example, you might want to get rid
of a value label temporarily, and/or reinstate
it later. In doing that you would usually prefer
not to re-attach that label to all those variables
to which it was previously attached. Of course, that's
in your head, and Stata has no way of knowing that, but
it can only wait and listen.

Remember: defining a value label and attaching it
to a variable are quite distinct. The principle
applies to deletion as much as it applies to creation.

It is not, for example, an error to attach a value
label that does not yet exist to a variable.

Nick
n.j.cox@durham.ac.uk

Philip Ryan

> I think this curiosity has apeared on the list before.  It's
> easy to reproduce:
>
> . sysuse auto
> . label dir
> origin
>
> . d foreign
>
>               storage  display     value
> variable name   type   format      label      variable label
> --------------------------------------------------------------
> -----------------
> foreign         byte   %8.0g       origin     Car type
>
> . label drop origin
>
> . label dir
>
> . d foreign
>
>               storage  display     value
> variable name   type   format      label      variable label
> --------------------------------------------------------------
> -----------------
> foreign         byte   %8.0g       origin     Car type
>
>
> to get rid of it:
>
> . label values foreign
> . des foreign
>
>               storage  display     value
> variable name   type   format      label      variable label
> --------------------------------------------------------------
> -----------------
> foreign         byte   %8.0g                  Car type
>
>
> I don't know if this constitutes a feature or a bug. It sort
> of reminds me of
> being in a restaurant, ordering the fish _on the menu_ and
> then being told the
> kitchen has run out of fish.

Quoting Fred Wolfe <fwolfe@arthritis-research.org>:

> > Using Stata 9.2, up to date, I am trying to convert a
> series of dta files
> > to SAS format.
> >
> > After running for a while my program exits with the following error:
> >
> > "value label sex not found"
> >
> > When I examine the data I find the following:
> >
> >
> > . des sex
> >
> >                storage  display     value
> > variable name   type   format      label      variable label
> >
> --------------------------------------------------------------
> ----------------
> -
> > sex             byte   %12.0g      sex        Sex
> >
> > . unlabeled
> >
> >                   | Value
> > Variable         | Label     #values   unlabeled values
> >
> -----------------+--------------------------------------------
> ----------------
> ----------------------------------------------
> > questid          | questid        3
> > sex              | sex            2    0 1
> > ethnic1          | ethnic         5
> > metcriteria      | yesno          2
> > pcscard          | yesno          0
> > edlevel          | edlevel       16
> > marital          | marital        7
> > edcat            | edcode2        5
> >
> > . tab sex
> >
> >          Sex |      Freq.     Percent        Cum.
> > ------------+-----------------------------------
> >            0 |      1,570       77.61       77.61
> >            1 |        453       22.39      100.00
> > ------------+-----------------------------------
> >        Total |      2,023      100.00
> >
> > . label drop sex
> > value label sex not found
> > r(111);
> >
> >
> > So, -describe- finds the label, but no other program does.
> Also, I can't
> > delete the non-existent label.
> >
> > I don't know how the label got this way (sorry), for it
> usually shows:
> >
> > . ndbuse fixed
> > (Survey Fixed Table version of 19 Aug 2006)
> >
> > . label list sex
> > sex:
> >             0 Female
> >             1 Male
> >
> >
> > My question is this. While it is a small matter to relabel
> the variable, in
> > the program I am running I have >1,000 variables so I would
> like to fix or
> > bypass the problem under program control. Generically, how
> to I get rid of
> > a value label (that doesn't exist) such as this? Is my
> problem a bug or a
> > feature?

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

Fred Wolfe
National Data Bank for Rheumatic Diseases
Wichita, Kansas
Tel +1 316 263 2125
fwolfe@arthritis-research.org


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index