Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Multiple Sequential Merges


From   Steve Nakoneshny <scnakone@ucalgary.ca>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Multiple Sequential Merges
Date   Wed, 3 Apr 2013 06:01:03 -0600

I suspect that this may actually be an -append- problem rather than a -merge- problem, notwithstanding Maarten's excellent advice.

You state at the end of your post that all of the data files have the same "columns" (read: vars). -merge- should be used when you wish to combine datasets with different vars. -append- is to be used when you wish to add new obs to a dataset.

Steve

Sent via carrier pigeon

On 2013-04-02, at 11:36 PM, "Lisa Wang" <lhwang0925@gmail.com> wrote:

> Hi all,
> 
> I am unsure as to whether I am applying the merge function correctly
> or not. I would like to merge values from multiple spreadsheets/.dta
> files into one master sheet "master". Here is the code I have at the
> moment:
> 
> merge 1:1 ID using "C:\Users\Admin\Documents\Data1.dta", force
> 
> All good as it will merge all the data into my "master" and then put .
> (missing values) for all the observations where it is not matched.
> However, if I then run:
> 
> merge 1:1 ID using "C:\Users\Admin\Documents\Data2.dta", force
> 
> then the values from Data2 do not appear in my "master" file even
> though the results say it has been merged (i.e. still appears as . )
> 
> What I want to achieve is similar to a VLOOKUP in Excel over multiple
> sheets but I thought I would just do a merge in STATA instead.
> 
> Data1, Data2, Data3...files all have the same columns as each other if
> that is any assistance.
> 
> Thank you,
> Lisa
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index