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

st: Re: Question about merging two datasets


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: Question about merging two datasets
Date   Sun, 31 Aug 2003 16:34:48 -0400

This appears to be a most basic merge.

assuming that dataset A is already sorted by city, then:

use B
sort city
merge city using A


These commands will result in a combined dataset where the value of income
from B takes precedence.

Michael Blasnik
michael.blasnik@verizon.net

----- Original Message ----- 
From: "Michael Horowitz" <horowitz@fas.harvard.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Sunday, August 31, 2003 4:08 PM
Subject: st: Question about merging two datasets


> I have a problem that I was wondering if someone out there could help me
> with. I have two datasets.  Lets call them dataset A and dataset B.
> Dataset A contains contains two variables, <city> and <income>.  Dataset B
> also contains two variables, <city> and <income>.  Dataset A is much
> larger than Dataset B and the data in Dataset B is more accurate than the
> data in Dataset A.  Specifically, the income levels for the cities in
> dataset A are sometimes incorrect and I need to replace them with the
> correct income levels from dataset B.
>
> So I need to merge datasets A and B, matching for when the name of the
> city is the same and inserting the income score from dataset B into
> dataset A when the two disagree.
>
> I've tried the various merge commands but I cannot seem to get the command
> right to make it work.
>
> Could someone please assist?  I would be quite appreciative.
>
> Sincerely,
> Michael Horowitz
>
>
****************************************************************************
*******************************
>
> Michael Horowitz
> 78 Kirkland Street, #1
> Cambridge, MA 02138
>
>
> *
> *   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/
>


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