Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: code for merging data


From   Prakash Singh <prakashbhu@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: code for merging data
Date   Mon, 21 Jan 2013 12:42:17 +0530

Dear stata listers
I need help in correcting my programming code to merge data set. I am
using stata 10.

I have 7 stata data files which I need to merge. I wrote code for this
but it is only merging last data file to the first one. Please suggest
me something on this, my code is

clear
set mem 700m
set more off
tempfile mydata
foreach l of numlist 4/9 {
   use lev3_1.dta
   merge commonid using lev`l'_1.dta
   capture merge using `mydata'
   ren _merge merge3_`l'
   save `mydata', replace
}

Please suggest me that where is the mistake happening in this code.


Regards
Prakash
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index