TA Stat wrote:
How can I read and combine, in Stata, multiple DBF files with the same
variables all in once.
--------------------------------------------------------------------------------
Your post's title said "merging", but by "combine" I assume that you want to
append them (UNION ALL in SQL).
If you're working in Windows, then you could use ODBC to read the dBase files
into Stata and append them. It would look something like the do-file below.
For the example, I had set up a user DSN via Windows Control Panel to read dBase
IV files and named the DSN "dBase IV". (StataCorp's website has details on how
to set up DSNs, I believe.) The do-file below combines three dBase IV files
named First.dbf, Second.dbf and Third.dbf.
If you're going to be doing this type of task a lot, then look into licensing
Stat/Transfer ( www.stattransfer.com ). It will pay for itself in convenience
and time saved.
Joseph Coveney
clear *
set more off
tempfile tmpfil0
odbc load, table(First) dsn("dbase IV")
save "`tmpfil0'"
foreach dbf in second third {
odbc load, table(`dbf') clear
append using "`tmpfil0'"
save `tmpfil0', replace
}
erase "`tmpfil0'"
quietly compress
save AppendedDBFs
exit
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/