Statalist The Stata Listserver


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

Re: st: Question RE: merging files


From   "ricardo sierra" <ricardo.sierra@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Question RE: merging files
Date   Thu, 26 Apr 2007 16:34:23 -0400

Dear Ferdinand,

Make sure that both your data sets are sorted by the variable county.

The following works:

use county_file.dta, clear
sort county
save, replace

use person_file.dta, clear
sort county
save, replace

merge county using county_file.dta


With the new data set looking like this:

person	county	age	population	_merge
1	1	20	15000	3
2	1	34	15000	3
3	1	17	15000	3
4	2	16	14089	3
5	2	23	14089	3
6	2	45	14089	3



On 4/26/07, S J <skj0200@yahoo.com> wrote:
Dear all,

I have two files, one is person level, one is county
level. To illustrate:

PERSON LEVEL FILE (person_file.dta):

person  county   age
1       1        20
2       1        34
3       1        17
4       2        16
5       2        23
6       2        45


COUNTY LEVEL FILE (county_file.dta):

county   population
1        15000
2        14089

I would have thought that I could merge these two by
stating (while using person_file.dta as memory):

merge county using county_file.dta

But Stata does not like that.

Sorry if this is a dumb question. I am a total newbie.

Best.

Ferdinand.




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
*
*   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–2023 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index