Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: merging on same using dataset


From   "Munro, Cameron" <[email protected]>
To   <[email protected]>
Subject   st: merging on same using dataset
Date   Fri, 3 Feb 2006 08:31:50 -0800

I'm building up a choice dataset where I need to read in the characteristics of the alternatives for each individual. A simplified example of what I want to happen:
Master data -
Indiv    Choice
1        2 
2        4
...      ...

Using data -
Choice  x1   x2 ...
1       10   12
2       14   13
3       17   18
4       43   13
5       12   15

Desired output -
Indiv  Choice  x1  x2  _merge
1      1       10  12     2
1      2       14  13     3
1      3       17  18     2
1      4       43  13     2
1      5       12  15     2
2      1       10  12     2
2      2       14  13     2
2      3       17  18     2
2      4       43  13     3
2      5       12  15     2

In effect, what I want to do is merge sequentially down each observation in the master dataset in turn. The only way I can achieve this at the moment is to create separate files for each obs and then append them together after running the merge on each separately. But this results in many files, and is slow. Is there a better way?

Cheers

Cameron.

--------------------

This email message is for the sole use of the intended recipient(s) and
may contain privileged information. Any unauthorized review, use,
disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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