Statalist


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

Re: st: Generating exact copy of variable


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: Generating exact copy of variable
Date   Fri, 15 May 2009 09:42:39 -0400


See  -help clonevar-



Philipp Rehm wrote:
Dear all,

is there a way to generate an exact copy of a variable? By "exact copy", I mean a variable with the same storage type, display format and value label. (I can't use -rename- for my problem). I am using Stata/SE 10.1, Windows XP.

Below is an example of the problem I ran into.

Many thanks,
Philipp


. gen test_id= id

. compare test_id id

                                        ---------- difference ----------
                            count       minimum      average     maximum
------------------------------------------------------------------------
test_id<id                 543121          -121    -4.120179          -1
test_id=id                  79808
test_id>id                 157474             1     19.96243         127
                       ----------
jointly defined            780403          -121     1.160693         127
                       ----------
total                      780403

. d test_id id

              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------------------------------------------------------------
test_id         float  %9.0g
id              double %10.0g                 personal id

. gen double test2_id= id

. compare test2_id id

                                        ---------- difference ----------
                            count       minimum      average     maximum
------------------------------------------------------------------------
test2_id=id                780403
                       ----------
jointly defined            780403             0            0           0
                       ----------
total                      780403



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index