Statalist The Stata Listserver


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

st: append, empty?


From   Jeph Herrin <junk@spandrel.net>
To   statalist@hsphsun2.harvard.edu
Subject   st: append, empty?
Date   Wed, 05 Jul 2006 11:35:28 -0400

This is not a question, just a request concerning a minor
nusiance, though there may be a solution I don't see.

I often have to patch together a large number of files with
identical format, but check for errors that depend on the file
index after appending each. Currently, the best way I can find
to do this is, eg,


  forv x=1/100 {
	if `x'==1 {
		use file1, clear
	}
	else {
		append using file`x'
	}
         [check things depending on `x']
  }

However, sometimes I don't know what the first file number is - or the
intervening file numbers - so I have to trap this. It gets very messy.
Ideally, -append- would have an "empty" option, so that  if there is no
dataset, -append- would -use-. Then I could just code

  clear
  forv x=1/100 {
         capture append using file`x', empty
         [check things depending on `x']
  }


See how much cleaner? Is there a logical reason why this would not work?
I don't see how it would but any existing data at risk. Or is there a
better way?

cheers,
Jeph
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index