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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Combining value labels, appending


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Combining value labels, appending
Date   Thu, 12 May 2011 08:56:04 +0100

These are, strictly, sets of value labels.

Something could be written to do this. A good program would indeed
check for overlap and have rules to determine what overwrites what.

See also -multencode- from SSC.

A quick and dirty way for the easy case:

forval i = 16/30 {
local label : label numbers2 `i'
label define numbers1 `i' `"`label'"' , add
}

Nick

2011/5/12 Jorge Eduardo Pérez Pérez <perez.jorge@ur.edu.co>:
>
> Is there a way to combine two value labels into a single one? Suppose
> I have two value labels:
>
> label list numbers1
>
> 1 One
> 2 Two
> ...
> 15 Fifteen
>
> label list numbers2
>
> 16 Sixteen
> ...
> 30 Thirty
>
> and I want to combine them into a single value label, numbers
>
> 1 One
> 2 Two
> ...
> 30 Thirty
>
> The issue that motivates the previous question is the following: I am
> appending two datasets with the same variable, which have a value
> label with the same name attached. However, the labels are not the
> same because they have different number-label assignments that
> overlap, i.e
>
> use data1, clear
> label list label1
>
> 1 One
> 2 Two
> 3 Three
>
> use data2, clear
> label list label1
>
> 2 Two
> 3 Three
> 4 Four
>
> and I want to append the datasets, keep label1 attached to the
> original variable and update label1 so it ends like
>
> label list label1
>
> 1 One
> 2 Two
> 3 Three
> 4 Four
>
> Of course this should only work if the labels coincide for the numbers
> that overlap. Is there a way to do this automatically?
>

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