Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

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


From   Ronan Conroy <rconroy@rcsi.ie>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
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
=================================

rconroy@rcsi.ie
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?)
http://rcsi.academia.edu/RonanConroy

P    Before printing, think about the environment





*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index