Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Merging files


From   Rafal Raciborski <[email protected]>
To   [email protected]
Subject   Re: st: Merging files
Date   Wed, 16 Feb 2005 19:38:11 -0500

Oops, sorry, I was tinkering with variable names and they did not come through
the right way. The correct example is below.
rafal

. use C:\temp\using.dta
. list

     +----------------+
     |   zip   no_org |
     |----------------|
  1. | 12345       23 |
  2. | 23456       41 |
  3. | 34567       19 |
  4. | 56789       56 |
     +----------------+

. sort zip
. save, replace
.
. use C:\temp\master.dta, clear
. list

     +-----------------+
     | resp_id     zip |
     |-----------------|
  1. |       1   12345 |
  2. |       1   23456 |
  3. |       1   34567 |
  4. |       2   12345 |
  5. |       3   23456 |
     |-----------------|
  6. |       3   56789 |
     +-----------------+

. sort zip

. merge zip using C:\temp\using.dta
. sort resp_id zip
. list

     +-----------------------------------+
     | resp_id     zip   no_org   _merge |
     |-----------------------------------|
  1. |       1   12345       23        3 |
  2. |       1   23456       41        3 |
  3. |       1   34567       19        3 |
  4. |       2   12345       23        3 |
  5. |       3   23456       41        3 |
     |-----------------------------------|
  6. |       3   56789       56        3 |
     +-----------------------------------+

. drop _merge


================
Rafal Raciborski
Graduate student
Department of Political Science
Emory University
301 Tarbutton Hall
1555 Dickey Drive
Atlanta, GA 30322
404-378-9826 (home)
[email protected] (e-mail)
www.roofoos.net

*
*   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