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

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

From   "Newson, Roger B" <[email protected]>
To   <[email protected]>
Subject   RE: st: Does a do file know its own name?
Date   Thu, 16 Aug 2007 18:29:38 +0100

If you want a version of -do- (renamed appropriately) that creates the
log file (named appropriately), then download the -dolog- package from
SSC by typing

ssc desc dolog
ssc inst dolog, replace

If you then type

dolog mydofile

then Stata will execute and output the results to
-mydofile.log- (as well as echoing them to the Results window).

I hope this helps.


Roger Newson
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected] 
Web page:
Departmental Web page:

Opinions expressed are those of the author, not of the institution.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Austin
Sent: 16 August 2007 17:18
To: [email protected]
Subject: Re: st: Does a do file know its own name?

As far as I know, no.  This would be a natural addition though, and I
have heard at least one request for this at Users Group meeting.

  creturn list
to see where a section on "Currently running" or somesuch would be
natural, with perhaps:
            c(dofilename) = ""
            c(dofilepath) = ""
            c(adofilename) = ""
            c(adofilepath) = ""

One workaround for do-files is to create your own versions of -do- and
-run- (renamed appropriately) that create the log file and then -do-
or -run- the do-file.  Another option is to use batch-mode processing
which creates a do-file of the same name by default, and also runs a
whole lot faster.

On 8/16/07, Skinner Jane Dr (MED) <[email protected]> wrote:
> Hi
> 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.
> Thanks,
> Jane
*   For searches and help try:

*   For searches and help try:

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