Statalist


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

Re: st: RE: How to put a prefix on a categorical variable that still carries label values?


From   "Jia Xiangping" <jiajoseph@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: How to put a prefix on a categorical variable that still carries label values?
Date   Thu, 28 Feb 2008 12:03:53 -0500

Thanks a lot, Nick.

I just went through the commands of -labutil-, and found they are
quite useful. I should have known this earlier.



On 2/28/08, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> I understand this as follows:
>
> Suppose variable -x- has values 11, 12, 13, ... and value labels "A", "B", "C", ....
>
> You want -y- to have values 111, 112, 113, ... and the corresponding value labels.
>
> Try
>
> gen y = 100 + x
> labmask y, values(x) decode
>
> Here -labmask- is in -labutil- on SSC.
>
> Nick
> n.j.cox@durham.ac.uk
>
> Jia Xiangping
>
> A variable in int storage type, reflecting different regions.
>
> label                             region code
> value
> 11                      A
> 12                      B
> 13                      C
> 21                      D
> 22                      E
> 23                      F
> 31                      G
> 32                      H
>
> Now I want to generate a new variable with a prefix "1" denoting the
> country code. But the variable still carry the codes.
> 111                     A
> 112                     B
> 113                     C
> 121                     D
> 122                     E
> 123                     F
> 131                     G
>
> How shall I do that with -recode-? Or there are some other commands for that?
>
> *
> *   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/
>


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