Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Tilahun, Negussie (CMS/CMMI)" <Negussie.Tilahun@cms.hhs.gov> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | st: merging multiple files in stata |
Date | Thu, 22 Mar 2012 10:17:49 -0400 |
Hello! I am an experienced sas programmer but I just started to work with stata. How can I merge multiple files? I can merge two files successfully but merging more than two becomes difficult. The program below run without error but I don't get the result I expected. i.e. after I merged the third file, the output file, temp_hsps, doesn't contain data from all the three files - it contains data only from the first two files. Thanks, Negussie Here is my code clear all set mem 500m use "C:\UserFiles\physndata.dta", clear compress rename pp_mnth mnth sort bene_id mnth, stable keep bene_id mnth pp_mnthexp save "C:\UserFiles\temp_physn.dta", replace use "C:\UserFiles\hspsdata.dta", clear compress rename hs_mnth mnth sort bene_id mnth, stable keep bene_id mnth hs_mnthexp save "C:\UserFiles\temp_hsps.dta", replace use "C:\UserFiles\temp_physn.dta" merge bene_id mnth using "C:\UserFiles\temp_hsps.dta" sort bene_id mnth drop _merge use "C:\UserFiles\opmnth.dta", clear compress rename op_mnth mnth sort bene_id mnth save "C:\UserFiles\temp_opmnth.dta", replace use "C:\UserFiles\NT\suraphl\temp_opmnth.dta" merge bene_id mnth using "C:\UserFiles\temp_hsps.dta" sort bene_id mnth drop _merge ......
Attachment:
smime.p7s
Description: S/MIME cryptographic signature