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


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