Statalist


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

st: append to an empty dataset


From   "Sergiy Radyakin" <serjradyakin@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: append to an empty dataset
Date   Mon, 3 Nov 2008 11:35:37 -0500

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/



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