Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • creating log files from -do- command

    Greetings

    I wanted to suggest a Stata feature for creating log-files as part of the -do- command. For example, say that the -do- command could take an option -log- or an
    option -smcl-. Then, if I run

    Code:
    . do test, smcl
    A file test.smcl would contain the log file results (as a .smcl file). Similarly, if I typed.

    Code:
    . do test, log
    A file test.log would contain the log file results (as a .log file).

    I know that there are user-written tools for this task, but it seems like it would be an extremely handy feature to have this as a built in feature as part of the -do- command.

    Any thoughts?

    Michael

  • #2
    I accomplish something similar to what you want, with a few extra features I find useful, using the following ado-file, which is stored in my personal ado directory.
    Code:
    program mydo
    
    log using `1', text replace name(`1')
    set more off
    display " directory:  `c(pwd)'"
    
    capture noisily do `1'
    
    set more on
    log close _all
    
    end
    So when I issue the command mydo test, a text logfile test.log is created, more is turned off so test.do will run without pausing, and my current working directory is entered into the log. Then test.do is run using capture (so that if it fails control returns to mydo) noisily (so that the output is not suppressed as it normally would be with capture). When test.do exits, more is turned on again, which is how I want it for interactive work, and the log is closed (which it would not be if control were not returned to mydo.ado after a failure to test.do).

    Perhaps this can serve as a starting point for you.

    Comment


    • #3
      StataCorp could add this.

      My wild guess is that the number of users who would get confused because they already have a log file open, or because they would start doing this with nested do files, is much greater than those who can find other ways to do this.

      Comment

      Working...
      X