Announcement

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

  • LOG file won't close

    Dear all,

    I am facing a problem for which I didn't find anything on the Internet.
    I am running a master do-file containing several sub do-files. I wanted to save the output using as much log files as I have calculus procedures in my master do-file. Unfortunately, the first log first won't close. Stata tells me "no log file open" and stop running. Then, when I try to rerun my master do-file, Stata tells me "log file already open". Removing "log close" and using "capture log close" at the beginning of the master do-file prevent Stata from stopping, but then my log files never stops and keep recording the entire outputs which is not what I want...

    Here is a piece of code from the master do-file:

    Code:
    # delimit ;
    
    log using"D:\Results\alone.log", replace name(alone);
    
    use "D:\Data\merged_14-13-12.dta", clear;
    quietly do "D:\Do_files\CLEANING1.do";
    quietly do "D:\Do_files\CLASS1.do";
    do "D:\Do_files\METHOD1.do";
    clear;
    
    log close;
    
    log using"D:\Results\alone2.log", replace name(alone2);
    
    use "D:\Data\merged_11-10-09.dta", clear;
    quietly do "D:\Do_files\CLEANING1.do";
    quietly do "D:\Do_files\CLASS1.do";
    do "D:\Do_files\METHOD1.do";
    clear;
    
    log close;
    I don't now if it helps but note that each sub do-file contains "clear" or "clear all" codes and "quietly{}" codes.

    Here is the Stata output at the end of the first run and the beginning of the second run:

    Code:
    ..............
    . save "D:\Data\morg_new1.dta", replace;
    file D:\Data\morg_new1.dta saved
    
    .
    end of do-file
    
    . clear;
    
    . log close;
    no log file open
    r(606);
    
    end of do-file
    
    r(606);
    
    . do "D:\Do_files\MASTER_SHEET.do"
    
    . # delimit ;
    delimiter now ;
    
    . log using"D:\Results\alone.log", replace name (alone);
    log file already open
    r(604);
    
    end of do-file
    
    r(604);
    Anyone with an idea of what is going on? I'm using Stata 12 64bits.

  • #2
    I think I fixed my problem.
    2 mistakes in the code:
    - A space was missing after each "log using"
    - Naming a log requires to call the name when closing it.

    Comment

    Working...
    X