Statalist


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

st: Re: Reading/Appending SEVERAL files using INSHEET


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: Reading/Appending SEVERAL files using INSHEET
Date   Fri, 24 Aug 2007 12:44:00 -0400

..Here's a basic approach, assuming that your files to insheet are all named *.csv (otherwise change the local files command)

local i=0
cap erase mybigfile.dta
local files : dir . files "*.csv"

foreach f of local files {
drop _all
insheet using "`f'"
if `i'>0 append using mybigfile
save mybigfile, replace
local i=1
}


You may encounter problems if the insheet commands create some variables as string for some files and numeric for others. This tends to happen more than you might like and could require some additional code to check and fix problems.

M Blasnik


----- Original Message ----- From: "John A Karikari" <KarikariJ@gao.gov>
To: <statalist@hsphsun2.harvard.edu>
Sent: Friday, August 24, 2007 11:44 AM
Subject: st: Reading/Appending SEVERAL files using INSHEET



Can someone please show me how to read and append SEVERAL (over 500!) files using "INSHEET"?
Thanks,

John Karikari
GAO
*
*   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