Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: append to an empty dataset


From   Jeph Herrin <junk@spandrel.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: append to an empty dataset
Date   Mon, 03 Nov 2008 14:12:46 -0500


Sergiy,

I posted this same question two years ago:

http://www.stata.com/statalist/archive/2006-07/msg00097.html

and received no satisfactory response. I often have the
same problem you have, and proposed that -append- have an
-empty- option, for instance, so that I can force it to
use the file if there is nothing in memory. I guess it will
have to go on a wishlist for StataCorp.

cheers,
Jeph


Sergiy Radyakin wrote:
Dear all,

is there any reason for -append- to refuse to run when there is no
data in memory?

clear
append using something.dta

I often have a list of files to combine, and go with a simple loop,
but when none of them is in memory, I have to brunch the program to
specially treat the first file in the list, which is annoying. Since
-append- is built-in, I can't look into what it is doing or needing.
Otherwise I wish -append- worked as -use- when there is no data in
memory. So that the below code could work.

local bunch_of_files "alpha beta gamma delta"
clear
foreach file of local bunch_of_files {
  append using `"`file'"', nolabel
}

Notably it is not the observations that -append- requires, but
variables, e.g. the following works:

local bunch_of_files "alpha beta gamma delta"
clear
generate byte __STRANGE_VAR_NAME=1 /* still zero observations here */
foreach file of local bunch_of_files {
  append using `"`file'"', nolabel
}
drop __STRANGE_VAR_NAME

Thank you, Sergiy Radyakin
*
*   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/

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



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