Announcement

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

  • Error in if loop

    I want to replicate the paper Drechsler, I., Savov, A., & Schnabl, P. (2021). Banking on deposits: Maturity transformation without interest rate risk. The Journal of Finance, 76(3), 1091-1143. and use their replication code. However, I keep having the error "==1 invalid name r(198);" when I try to run the following code:


    if `run_SU_01' == 1 {
    include "`setup_code'SU_01_main_setup.do"
    }

    I tried several ways: align the code in one row, delete the space (use ==1 rather than == 1), use = 1 , which did not work.

  • #2
    The immediate reason is probably that the local macro run_SU_01 is not defined (visibly to the code running). Your work-arounds are either illegal or ineffective. Your code must be able to see the definition of run_SU_01

    Comment


    • #3
      Either the local macro run_SU_01 is not defined in your code, or you are running this bit of code by itself, in which case the local macro is not in Stata's memory. When it doesn't recognise the macro, Stata does not complain, but regards this as intentional and treats the result as empty. So it is reading your first line as:
      Code:
      if == 1 {
      which results in exactly the error you are getting.

      Comment

      Working...
      X