Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: -labellacking- available on SSC


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: -labellacking- available on SSC
Date   Tue, 2 Jul 2013 17:16:38 +0100

Last month Toby Robertson started a thread on detecting which values
of numeric variables are unlabelled when value labels have been
defined.

The thread starts at
http://www.stata.com/statalist/archive/2013-06/msg01004.html and
featured contributions by

Peter Lachenbruch
Steve Nakoneshny
Richard Goldstein
Robert Picard
and myself

and suggestions of various approaches based on

-tabulate-
-codebook-
-labelbook-
-decode-

and a more complicated combination of commands by Toby himself.

A rough program -labellacking- based on Robert's suggestion of using
-decode- was posted in
http://www.stata.com/statalist/archive/2013-06/msg01033.html in the
face of some scepticism.

Now thanks as ever to Kit Baum's help a more polished version by
Robert and myself can be downloaded from SSC using -ssc inst
labellacking-.

The objection was to introducing what could be a long string variable
into an already large dataset, but the code in -labellacking- produces
only a temporary -str1- variable, which is sufficient to detect
missing string values that correspond to non-defined value labels.

Stata 8.2 is required. If you are interested you can install via
-ssc-, but for the indefinitely curious some quick examples follow my
signature. The default of -labellacking- is to ignore extended missing
values, to ignore variables with all values assigned value labels and
especially to ignore numeric variables without any value labels
defined at all, but all those defaults can be reversed.

Nick
[email protected]

. sysuse auto, clear
(1978 Automobile Data)

. label define rep78 1 abysmal 2 adequate

. label val rep78 rep78

. labellacking price-foreign
rep78   3 4 5

. labellacking price-foreign, all
rep78     3 4 5
foreign   (none)

. labellacking price-foreign, all report
price          (no value label)
mpg            (no value label)
rep78          3 4 5
headroom       (no value label)
trunk          (no value label)
weight         (no value label)
length         (no value label)
turn           (no value label)
displacement   (no value label)
gear_ratio     (no value label)
foreign        (none)

. labellacking rep78, missing
rep78   3 4 5

. replace rep78 = .a if rep78 == .
(5 real changes made, 5 to missing)

. labellacking rep78, missing
rep78   3 4 5 .a
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index