Announcement

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

  • "Unexpected end of do-file" in middle of .do file

    Hi all,

    I have a curious problem. I have a master .do file (Master.do) which calls a number of other .do files. When one of these is running, it gives the error "unexpected end of do-file" in the middle of the .do file. Oddly, if I simply call that child .do file directly (rather than getting Master.do to call it), there is no problem. The error appears during the running of this code:

    Code:
    save "${interimpath}//LFSInterim1", replace
    
    
    ******************************************************************************************************************************************************************
    
    import excel using "${miscdatapath}//taxrates.xlsx", firstrow sheet("output") clear
    tempfile taxrates
    save `taxrates'
    
    
    
    u "${interimpath}//LFSInterim1", replace
    
    //Recode various vars
    replace ayfl19 = -1 if ayfl19 == 19
    The .do file is considerably longer than above, with code both above and below - this is just the relevant part. After "save `taxrates'", Stata gives the "unexpected end of do-file" error.

    I am running version 16.1 MP if relevant. I have tried adding and subtracting blank lines after "save `taxrates'" but to no avail. Annoyingly the part of the code above the snippet above takes a considerable amount of time to run making testing different fixes difficult.

    Grateful for any help.

  • #2
    What is the output of:

    Code:
    tempfile f
    di "`f'"

    Comment


    • #3
      Change
      Code:
      save `taxrates'
      to
      Code:
      save `"`taxrates'"'
      But this doesn't explain why the code is running fine when executed directly, not from the master.do. Imho the culprit may be there, in the setting of the globals, or the way how this child file is called. Check if any of the globals/paths contain any quotes/apostrophes, such as "1980's", or "Data of John O`Hare".

      Comment

      Working...
      X