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: executing commands on exit

From   A. Berâ <>
Subject   Re: st: executing commands on exit
Date   Tue, 13 Sep 2011 16:43:49 +0300

Sometimes I start working with Stata and regret failing to open a log
file. So I would likte to open a log file with a temporary name and
close it whan I exit Stata. I can save the file later if I want to. If
not, next Stata session will overwrite this log file.

Similarly, in many cases I simply exit Stata without remembering to
close the log file.

When I use the following lines, the log file is opened but the date
and time is not displayed in the created log file (I don't know why)
cd "D:\Documents and Settings\My Documents\work"
log using temp.log, name(temp) replace

As Phil suggested I added the term "noisily" and date and time is
displayed now.
cd "D:\Documents and Settings\My Documents\work"
noisily log using temp.log, name(temp) replace

So the log file is opened automatically when executes the
lines above, and the Stata closes the log file when I exit Stata but
without time and date at which the file closes.

Finally, even if I close the log file manually (after my
executes the lines above and the log is opened automatically), I get
the following message.

running c:\ado\personal\ ...
      name:  temp
       log:  D:\Documents and Settings\bgmbkta\My
  log type:  text
 opened on:  13 Sep 2011, 16:42:22

//following commands are not in the do file. opens the log file only.
. sysuse auto
(1978 Automobile Data)

. list make price in 1

     | make          price |
  1. | AMC Concord   4,099 |

. log close
no log file open


On Tue, Sep 13, 2011 at 4:23 PM, Neil Shephard
<> wrote:
> On 13 September 2011 14:15, A. Berâ <> wrote:
>> Yes but I also want to have closing date and time as we would see if
>> we closed the log file manually.
> Why have this as part of your "global" Stata session?
> Common practice is to open a log-file at the start of your do-file and
> then close it at the end of the do-file.
> That will record the start and finish dates/times on which you run your do-file.
> Having a log-file open as part of a Stata session could potentially
> cause problems if you then try and run a do-file that records its own
> log as you can't have two log-files open at a given time.
> Is it much more effort to type five characters to close the log-file
> prior to exiting?
> . log c
> . exit, clear
> Neil
> --
> "To consult the statistician after an experiment is finished is often
> merely to ask him to conduct a post mortem examination. He can perhaps
> say what the experiment died of." ~ R.A. Fisher, Presidential Address
> to the First Indian Statistical Congress, 1938
> Neil Shephard
> Clinical Trials Research Unit /
> NIHR Research Design Service for Yorkshire & the Humber
> University of Sheffield
> *
> *   For searches and help try:
> *
> *
> *

abdullah berâ

*   For searches and help try:

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