Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: how to attach labels to string values


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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
<stephen.martin@york.ac.uk> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index