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

Re: st: label after recode

From   Svend Juul <SJ@SOCI.AU.DK>
Subject   Re: st: label after recode
Date   Thu, 20 Mar 2008 11:18:08 +0100

Chris wrote:
in order to fit the distribution of wildtypes/genotypes in my 
population, I want to change the order of the values coded in
I'm using the recode command:
. tab z1_gene_x
group(z1_ge |
ne)         |    Freq.    Percent      Cum.
          G |        8       0.17      0.17
          T |    4,684      99.83    100.00
      Total |    4,692     100.00
. recode z1_gene_x 1=2 2=1
(z1_gene_x: 4692 changes made)
. tab z1_gene_x
group(z1_ge |
ne)         |    Freq.    Percent      Cum.
          G |   4,684       99.83     99.83
          T |       8        0.17    100.00
      Total |   4,692      100.00
It seems like recode actually does what it is supposed to.
However, it does not change the label, what is somehow confusing.
According to the manual, recode supports the label option, 
but not for just keeping the label...
The manual and the online help says about -recode-'s -label()- 
   label(name) specifies a name for the value label defined 
         from the transformation rules.  label() may be defined 
         only with generate() (or its synonym, into()) and
You can define value labels within the -recode- command:
   . recode z1 (1=2 "G")(2=1 "T") , generate(z2) 
The label name becomes -z2-, unless you specify the -label()-
   . recode z1 (1=2 "G")(2=1 "T") , generate(z2) label(z2lab)
Your example illustrates the danger with -recode- without the
-generate()- option: you may change the meaning of codes in a 
way that may lead to serious mistakes. I wish that -recode- 
required either a generate() option or a -replace- option; 
it would be in line with the safety precautions built into 
Stata with other commands.
Hope this helps,
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 
DK-8000 Aarhus C,  Denmark 
Phone, work:   +45 8942 6090 
Phone, home:   +45 8693 7796 
Fax:           +45 8613 1580 

*   For searches and help try:

© Copyright 1996–2019 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index