Announcement

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

  • errors related to rangerun

    Hello all

    I ran into some problems when doing rangerun (from SSC). The problems seem to be solved if I change the name of the program, say to "myreg" instead of "reg".

    Code:
    clear all
    set obs 100
    set seed 1234
    gen day=_n
    gen y=runiform(1,10)
    gen x1=runiform(1,10)
    gen x2=runiform(1,10)
    
    cap program drop reg
    program reg
    reg y x1 x2  
    predict hat
    
    end 
    
    rangerun reg , interval(day -15 -1)  
    su hat // error: variable hat not found
    reg y x1 x2 // error: system limit exceeded - see manual
    Grateful for advice.

  • #2
    It is not legal to choose as a name for a program (or a variable) something that is already a command name in Stata, namely, reg. If you add the -verbose- option to your -rangerun- command, you will see that your program reg is not in fact being completed, and you will see the same error message "system limit exceeded - see manual" each time it is called.

    You may be wondering what the system limit that is exceeded is. Well, since you have appropriated the name reg for your own program, when you try to run it and it then encounters the command -reg- inside your program, it does not expand that -reg- into regress. Rather it thinks you are trying to again call -reg- recursively. Which leads to yet another recursive call to -reg- in what would be an infinite descent. But, of course, the program stack has some limit of depth and that a) keeps Stata from hanging and b) informs you that that stack depth limit has been exceeded.

    Moral of the story: don't use the same name for two different things.
    Last edited by Clyde Schechter; 06 Dec 2017, 21:09.

    Comment


    • #3
      Clyde Schechter . Thanks for the explanation!

      Comment

      Working...
      X