Statalist


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

Re: st: label after recode


From   Svend Juul <SJ@SOCI.AU.DK>
To   statalist@hsphsun2.harvard.edu
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
z1_gene_x.
 
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()- 
option:
 
   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
         prefix()...
 
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()-
option:
 
   . 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  
 
________________________________________________________ 
 
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 
E-mail:        sj@soci.au.dk 
_________________________________________________________ 


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