Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <n.j.cox@durham.ac.uk> |
To | "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |
Subject | st: RE: Basic Numeric to String Recoding |
Date | Mon, 6 Sep 2010 22:21:59 +0100 |
-recode- is not suitable for this purpose. It is for numerical to numerical recodes. Check out -decode-. But typically you will gain little or nothing. Stata prefers numeric variables with attached value labels. Nick n.j.cox@durham.ac.uk Benhoen2 I have a list of numeric IDs for states (stateid) with abbreviated labels attached (stname). I would like to create a new string variable made us of the unabbreviated state names but based on the stateid variable. I have tried the following: 1) recode stateid (1="Alabama"), (2="Arkansas"), ..., generate(statename) 2) recode stateid (1="Alabama"), (2="Arkansas"), ..., strgen(statename) 3) generate state="Alabama" if stateid=1 among other nonsensical permutations. Is there any way to do this using recode, or something analogous? * * 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/