Bookmark and Share

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   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: Working with the name of the do file
Date   Tue, 30 Apr 2013 22:49:49 -0400

There are many situations where it would be helpful to know the name of current -do- file; for instance, for version control. At the top of every do-file I usually put

  copy thisdofile.do copies/thisdofile.${now}.do, replace

where $now is a global containing a time stamp. This lets me identify the exact copy of a -do-file that created the output with the same time-stamp. However, it would be easier if I didn't have to remember to change the name of the file in this line whenever I changed the name of the do-file.

I have tried to implement this functionality - of keeping the name of the current do-file in a global - with a set of wrappers and globals, but one always runs into the problems when nesting do files - if one file calls another, it has to store the current value, update it, then return it back to the original value when it returns control to the calling do-file. Since there is no limit to the levels of nesting, this gets messy.

cheers,
Jeph



On 4/30/2013 7:36 PM, Nick Cox wrote:
Why would this make a .do file easier to use and maintain?
Nick
[email protected]


On 30 April 2013 23:38, 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/


*
*   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/


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