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

st: Re: Reading/Appending SEVERAL files using INSHEET

From   "Michael Blasnik" <>
To   <>
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" <>
To: <>
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"?

John Karikari
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index