Statalist The Stata Listserver


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

st: Appending several files


From   "Nuno Soares" <ns.mlists@gmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Appending several files
Date   Sat, 14 Oct 2006 12:42:37 +0100

Hi everyone,

I'm trying to make Stata to append several files that are in a given
directory without the need of specifying the name of each one. I was
thinking of doing something like this (using the fs package):

clear
cd "C:\data"
qui fs *
foreach f in `r(files)' {
append using `f'
}

The problem with this code is that Stata doesn't allow to append a data file
when it doesn't have a file opened (it will return the error message:
"no dataset in use
r(3)")

This means that I must have at least one of the files loaded in Stata before
using the above code. But if I then use the above code, I would end up
getting duplicate observations, because the file I've first used is also
appended... Any ideas of how to solve this issue?

Best,

Nuno



*
*   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