Bookmark and Share

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: creating a new variable


From   Gary Longton <[email protected]>
To   [email protected]
Subject   Re: st: creating a new variable
Date   Fri, 21 Jan 2011 16:48:32 -0800

<>
It is not clear what you mean by "the x variable is not consistent between the two tables", so I'll take a guess that it is one of the following two possibilities. Will assume Db parlance for "tables", i.e "datasets" in Stata.

If you mean that x is of different storage type in the 2 datasets - numeric in one and numeric values stored as string type in the other - then convert x in the latter using -destring- prior to merging (-help destring-).

If, on the other hand, you mean that there is not a complete overlap of x values (within combinations of ID and x2 values) between the datasets, -merge- will handle this and flag the origin of non-overlapping observations accordingly. This is fairly clearly explained in the help for -merge-.

Maybe you meant something else by "not consistent"? If so, please elaborate.

- Gary

On 1/21/2011 8:25 AM, King, Carina wrote:

I want to create a new 'x' variable as I need to merge two tables using ID, x, and x2 as the unique merging variables and the x variable is not consistent between the two tables. How can I do this?

ID   x        x2
1    51732    2
1    51732    3
1    51732    5
1    51732    8
1    33575    2
2    0        2
3    0        1
3    0        2
3    0        3
3    77890    4
3    77890    5
3    22345    6
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index