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: Concatenating two numerical variables with labels


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Concatenating two numerical variables with labels
Date   Mon, 6 Feb 2012 13:13:08 +0000

Evidently you want value labels: the expression "label of each
variable" is likely to be misread as meaning variable labels. The
syntax you were trying to use returns the name of the value label,
which is not what you want.

Try

egen Lab3 = concat(site2 site3), decode p(" ")

Nick

On Mon, Feb 6, 2012 at 12:56 PM, Tim Evans <[email protected]> wrote:

> I'm trying to generate a new string variable in Stata 11.2 which contains the concatenated result of two numeric variables which have labels. What I want is the name from the label of each variable rather than 1 1 for instance. I've seen code for concatenating string variables, but don't seem to be able to find this.
>
> I've tried this, but it does not give me a value of the label of two variables:
>
> gen Lab3
> replace Lab3 = `"`:label ( site2) '"' + `"`:label (sarc) '"'
>

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