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: copying contents form existing to new variable


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: copying contents form existing to new variable
Date   Wed, 24 Apr 2013 10:20:03 +0100

This could be as simple as your new variable not inheriting the value
labels of the -encode-d variable. (Have a look at -clonevar-.)

Otherwise, we need more evidence. What you do mean by the contents
changing? Show us the results of

. describe var1 var2
. su var1 var2
. list var1 var2 if var1 != var2        [example at least]

Nick
njcoxstata@gmail.com

On 24 April 2013 10:10, Patricia Biedermann <pati.stat@gmail.com> wrote:

> If I generate a new variable from an existing variable it happens that
> the contents get changed.
> gen var2=var1
>
> My approach is following:
> 1) My original variable is string and I - encode - it: var1
> 2) gen var2=var1
>
> At step 2) the contents changes.
> I came along this Thread:
> http://www.stata.com/statalist/archive/2012-05/msg01280.html
> ..and tried to create a double variable first before copying the
> variables. Anyway, the same problem appears again.
>
> What could be the problem? It did this thing (gen var2=var1) many
> times and it always worked so far...
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index