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

From |
"Sergiy Radyakin" <serjradyakin@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: append to an empty dataset |

Date |
Tue, 4 Nov 2008 12:41:28 -0500 |

On Tue, Nov 4, 2008 at 9:05 AM, Johannes Geyer <JGeyer@diw.de> wrote: > I had/have that problem too and most often I have to create a cycle and an > exception (the first data set). Reading throught your posts I thought why > not add that option -gen tempvar- to append when using it? > > Wouldn't that suffice?: Yes, and the program can be further improved to check if there are variables already present, and generate tempvar only for the empty dataset (because currently it will generate tempvar 100 times for 100 datasets, and only 1 is required). It can also brunch inside to use or append depending on whether there is anything in memory. In any case this special treatment of the first dataset is a very unnecessary effort, which could have been easily avoided. Thank you, Sergiy Radyakin > > ************** > program append_empty > syntax using [, *] > > tempvar qwerty > gen `qwerty' = 1 > > append `using', `options' > end > ************** > > ************** > clear > append_empty somedataset > ************** > > Johannes > > > ---------------------- > Johannes Geyer > Deutsches Institut für Wirtschaftsforschung (DIW Berlin) > German Institute for Economic Research > Department of Public Economics > DIW Berlin > Mohrenstraße 58 > 10117 Berlin > Tel: +49-30-89789-258 > > owner-statalist@hsphsun2.harvard.edu schrieb am 03/11/2008 22:07:30: > >> I'll back this request, too. I use -append- to combine my simulated >> files, and what I do is I create a -postfile- without actually >> -post-ing anything in it, so it comes out with zero observations and >> all the variable names needed. Something like that was done by Phil >> Schumm & co (am I attributing this right?) a few years back when they >> were setting up questionnaires and other survey-related >> characteristics of the data in the -notes- section of the file with >> zero observations, to be filled up later at actual the data collection >> stage. But I do think that -append-ing to the empty data set should be >> a reasonable thing to do. >> >> On 11/3/08, Jeph Herrin <junk@spandrel.net> wrote: >> > >> > 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/ >> > >> >> >> -- >> Stas Kolenikov, also found at http://stas.kolenikov.name >> Small print: I use this email account for mailing lists only. >> * >> * 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/ > * * 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/

**Follow-Ups**:**Re: st: append to an empty dataset***From:*"Austin Nichols" <austinnichols@gmail.com>

**References**:**Re: st: append to an empty dataset***From:*"Stas Kolenikov" <skolenik@gmail.com>

**Re: st: append to an empty dataset***From:*Johannes Geyer <JGeyer@diw.de>

- Prev by Date:
**st: List of class member programs** - Next by Date:
**Re: st: append to an empty dataset** - Previous by thread:
**Re: st: append to an empty dataset** - Next by thread:
**Re: st: append to an empty dataset** - Index(es):

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