Announcement

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

  • error while loading - message

    I have a lengthy do file which I want to turn into an ado file; I put the following at the top of the file, saved it with a new name as an ado file:

    Code:
    program define table6
    version 12.1
        args filename firstyear lastyear
    
    if "`filename'" == "" {
        noi di "What file do you want to use?" _request(_fname)
        us "`fname'", clear
    }
    else {
        us "`filename'", clear
    }
    
    if `firstyear'=="" {
        local minyr = real(substr(c(current_date),-4,.))
    }
    else {
        local minyr `firstyear'
    }
    if `lastyear'=="" {
        local maxyr = `minyear'+5
    }
    else {
        local maxyr `lastyear'
    }
    local denom=`maxyr' - `minyr' + 1
    
    noi mac li
    end
    I put the "noi mac li" and "end" so I could test the above only
    However, when I call this (with just table6 or with table6 followed by anywhere from 1 to 3 arguments, I get the following

    Code:
    (error occurred while loading table6.ado)
    r(9611);
    When I click on the blue-colored return code, I get this:

    Code:
    -------------------------------------------------------------------------------
    search for r(9611)                                        (manual:  [R] search)
    -------------------------------------------------------------------------------
    
    Search of official help files, FAQs, Examples, SJs, and STBs
    
    Web resources from Stata and other users
    
    (contacting http://www.stata.com)
    no matches
    (click here to return to the previous screen)
    
    (end of search)
    so, anyone have an idea what this error message should be? or, what I did incorrectly?

  • #2
    Have you checked -which table6- to make sure it's on your ado path? I can't replicate your problem. There are several bugs* in the code itself, but I don't get any complaints from Stata about loading the file.

    *You need quotes around `firstyear' and `lastyear' in your -if- commands referring to them.
    Where you calculate local maxyr, you refer to a non-existent local macro `minyear', which I imagine is supposed to be `minyr'.

    Comment


    • #3
      Copying your code, running it and calling

      Code:
      table6 foo.dta
      where foo.dta is some example dataset, I get

      Code:
      =="" invalid name
      with both, Stata 12.1 and 11.2 (after changing the version statement). This is to say, I cannot replicate your problem.

      I am running Win 7. Both Stata versions are fully updated.

      Best
      Daniel

      Comment


      • #4
        thanks for the tests - yes, I have checked "which":

        Code:
        . which table6.ado
        ./table6.ado
        so it is there

        thanks also for the bug notices

        I will try closing and re-opening Stata

        Comment


        • #5
          the problem was that the remainder of the do file appeared after "end"; once I added "exit" after "end" all was fine - thank again

          Comment

          Working...
          X