I think the answer to your subject question is No,
in several senses.
More seriously, what I think you want to do is
achievable in this way:
-------------------------------- mydo.do
log using `2'
di "dofile `1'"
do `1'
log close
--------------------------------
Then you would type something like this
do mydo foobar.do foobar.log
and -mydo.do- would first open a log, here
foobar.log, then echo the name of the
do-file, here foobar.do, then run said do
file.
There are endless possible small variations
on this. Filenames with embedded spaces
must be delimited by " " as usual.
However, this seems more indirect than
opening a log before issuing -do- or
-run-. That way, the name of the do
file is included in the log in any case.
Nick
[email protected]
Skinner Jane Dr (MED)
> Is there any way of obtaining the string "MyDoFile" programmatically
> from within MyDoFile.do? I would like to write to a log file with
> the same name (different extension, obviously) in a way that is
> robust to renaming or copying the do file, amongst other things.
*
* 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/