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: Combining value labels, appending
From
Nick Cox <[email protected]>
To
[email protected]
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 <[email protected]>:
>
> 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/