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

st: RE: Does a do file know its own name?

From   "Nick Cox" <>
To   <>
Subject   st: RE: Does a do file know its own name?
Date   Thu, 16 Aug 2007 17:07:48 +0100

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: 

log using `2' 
di "dofile `1'" 
do `1' 
log close 

Then you would type something like this 

do mydo foobar.log 

and would first open a log, here 
foobar.log, then echo the name of the 
do-file, here, then run said do

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. 


Skinner Jane Dr (MED)
> Is there any way of obtaining the string "MyDoFile" programmatically
> from within  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:

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