Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[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 <>
To   "" <>
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 arg1
    do arg2


If your 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 to write
to 'import.log' and to write to 'sort.log', etc.

Your can probably call, which in turn calls 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:

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.


On Tue, Apr 30, 2013 at 6:38 PM, daniel klein <> wrote:
> Old, but maybe this helps:
> 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:
> *
> *
> *
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index