Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | David Kantor <kantor.d@att.net> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: Wishlist for Stata 13 |
Date | Mon, 28 Jan 2013 16:32:14 -0500 |
Hello,I have a wish, based on Stata 10. So I don't know if this has been taken care of in Stata 11 or 12.
When using -confirm new file- or -confirm file-, it would be good if the file name could (optionally) be checked for the possibility of it being a .dta file. That is, suppose the filename is in a macro "filename", and my code looks like...
confirm new file `filename' ... save `filename' Most of the time, I should really check... confirm new file `filename'.dta--as Stata interprets `filename' as `filename'.dta when saving it as a dataset. Thus, if I test only
confirm new file `filename'and `filename' is "abc", and the file abc.dta exists, but abc (no dot) does not, then the -confirm- will pass, but the -save- will fail.
The solution would seem to be to test... confirm new file `filename'.dtaBut it is not always correct, either, as there is an exception: if the name already has a "." in it, then -save- does not append ".dta".
So the robust way to code this, as I see it, is... if strpos("`filename'", ".") { confirm new file `filename' } else { confirm new file `filename'.dta } or the equivalent one-liner: confirm new file `filename'`=cond(strpos("`filename'", "."), "", ".dta")'But I don't want to write all of that every time. It would be nice if that were built-in to -confirm-. Perhaps it would be a new syntax, such as -confirm new dta file- filename.
Has anyone else had this issue? ---- I had another wish, but can't think of it now. Thanks to Statacorp for listening. --David * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/