Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Working with the name of the do file
From
Sergiy Radyakin <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Working with the name of the do file
Date
Tue, 30 Apr 2013 19:52:33 -0400
Daniel has provided the link to the thread that discusses the issue.
In short, the answer is 'no' a do file does not know it's name.
Even if it did, in your scenario you are likely to face a problem of
program define external
do internal.do arg1
do internal.do arg2
end
If your internal.do is opening a log file with a fixed name, it will
overwrite the own output. If you are calling each do file only once,
there is no need to know it's name, just hardwire import.do to write
to 'import.log' and sort.do to write to 'sort.log', etc.
Your do1.do can probably call do2.do, which in turn calls do3.do etc.
So there will be a chain of the do-file names all of which are running
at the moment. A stack of names, which is exactly the stack of calls
or "call stack" present in most programming environments:
http://www.function1.com/site/2008/10/17/stack_trace_read_info.png
Stata has it's internal analog, but it does not allow accessing it
from the user programs.
If you want to do it, this usually means you are doing something, for
which other alternatives exist.
Sergiy.
On Tue, Apr 30, 2013 at 6:38 PM, daniel klein <[email protected]> wrote:
> Old, but maybe this helps:
>
> http://www.stata.com/statalist/archive/2007-08/msg00556.html
>
> Best
> Daniel
>
> --
> I want to make my Stata do files easier to use and maintain. Is there
> a way to access the name of the do file from within the do file
> itself, perhaps as a macro or a system variable?
> [...]
> *
> * 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/
*
* 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/