Bookmark and Share

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

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

Re: st: "Label define" syntax for "all other values"

From   Ronan Conroy <>
To   "" <>
Subject   Re: st: "Label define" syntax for "all other values"
Date   Fri, 24 Sep 2010 14:51:53 +0100

On 24 MFómh 2010, at 11:52, Nick Cox wrote:

The straight answer is that -label define- does not offer the syntax imagined. In addition to Eric's strategy, another is

clonevar rr_job2 = rr_job
replace rr_job2 = 5 if !inlist(rr_job, 1, 2, 3, 4)
label def rr_job2 1 "Driver" 2 "Conductor" 3 "Brakeman" 4 "Fireman" 5 "Stata user"
label val rr_job2 rr_job2

-recode- is here naturally an alternative to -replace-.

I was also asked this question the other day, by a SAS user. It seems to me that if you are allowed to label 'all other values' with a single label, this will require a pass through the data every time the variable has to be displayed to create a new variable which groups together the required values, slowing processing, perhaps significantly. This seems less efficient than simply recoding the variable and leaving it accessible in the dataset.

Ronán Conroy
Associate Professor
Division of Population Health Sciences
Royal College of Surgeons in Ireland
Epidemiology Department,
Beaux Lane House, Dublin 2, Ireland
+353 (0)1 402 2431
+353 (0)87 799 97 95
+353 (0)1 402 2764 (Fax - remember them?)

P    Before printing, think about the environment

*   For searches and help try:

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