Statalist The Stata Listserver


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

Re: st: Re: Appending several files


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: Re: Appending several files
Date   Mon, 16 Oct 2006 14:04:52 -0400

Good trick, I will use this. I recently advocated the addition
of an [empty] option to -append-, which would force -append- to
act like -use- if there were no dataset in memory. However, those
who don't often -append- didn't see the hardship in trapping the
first file.

cheers,
Jeph


Jens Lauritsen wrote:
A simple technique can be useful to "trick" Stata to behave like a dataset exists:
* create an empty dataset with one observation and one variable:
set obs 1
gen articifialvar = 1

* now you can do anything where Stata expects an open data set to be present, e.g. from
* the current discussion:
qui fs *
foreach f in `r(files)' {
append using `f'
}

* following appending all the files the first imaginary observation and variable can be dropped:
drop artificialvar
drop in 1

regards
Jens Lauritsen
Odense, Denmark

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


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index