Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: how to attach labels to string values


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: how to attach labels to string values
Date   Wed, 4 Jul 2012 12:28:39 +0100

Stata does not let you attach value labels to string variables. You
can use -merge- to bring the new text into your main dataset as a new
string variable. If need be you can then -encode- it. -labmask- (SJ)
and -sencode- (SJ) are other utilities in this territory. The strategy
is to see whether -encode- does what you want; if not then -labmask-
or -sencode- may offer what you want.

It depends on what you want to do, but two numeric variables with
different value labels can be used more widely than two string
variables.

Nick

On Wed, Jul 4, 2012 at 12:13 PM, Stephen Martin
<[email protected]> wrote:
> I have a variable with a three digit hospital operation code.  The
> first digit is always a letter and the other two digits are always
> numeric (eg A10, R45, V89).
>
> I have another file with a very brief description of the meaning of
> each of these codes.  I would like to use this information to attach
> labels to the operation code but the latter are not integers so I
> believe that I can't use label define lblname # "label" [# "label"
> ...].
>
> Is there an easier way around this apart from, say, replacing the
> first digit in the operation code with a number (i.e., replace A with
> 1, B with 2,...)?
>
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index