Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: Wishlist for Stata 13

From   Nick Cox <>
Subject   Re: st: Wishlist for Stata 13
Date   Mon, 28 Jan 2013 21:40:01 +0000

David and others on versions before the present can always access
basic help for the current version on-line:

The links at the foot of every Statalist posting give another example.

In this case I would try -quietly describe using <filename>- and see
if it's a Stata data file that you can read. If it's not, there will
be an error message.


On Mon, Jan 28, 2013 at 9:32 PM, David Kantor <> wrote:

> 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'.dta
> But 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?
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index