J's last paragraph is the way to approach this problem. Below is
a do-file which implements one possible solution. Comments are
embedded in the do-file explaining each step.
------------------------------------------------------------------
// clear any current data from memory
clear
// obtain list of filenames
local files : dir "." files "*.csv"
// (optional) sort list of filenames to ensure in alphabetical order
local files : list sort files
// create 'master' dataset from first file
gettoken first files : files
insheet using "`first'"
save master, replace
// loop over subsequent files
foreach fname of local files {
// make sure no data in memory
clear
// read a file, create a temporary Stata dataset from it,
// read in the master file, and append the temporary file
// to it, resaving the master at the end for the next
// iteration through the loop
insheet using "`fname'"
save temp, replace
use master
append using temp
erase temp.dta
save master, replace
}
// master dataset from all .csv files is now in memory
exit
------------------------------------------------------------------
Alan
ari...@stata.com