Announcement

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

  • Invalid name error

    Hello. I am using Stata 14.0 on Windows 10.

    I bumped into a trivial problem but don't know what to do.

    I was into a process making a simulation, however, while generating a variable, I am getting: + invalid name (error (r)198

    This is my code. I think there is some problem reading the "+" sign or "*" the multiple sign.

    Does anyone know how to solve the issue?
    Attached Files

  • #2
    Welcome to the Stata Forum / Statalist.

    I cannot test it now, unfortunately.

    Maybe you should try again, this time with no space between alpha_2 and beta_2.
    Best regards,

    Marcos

    Comment


    • #3
      The most likely reason for this error is an undefined (empty) local macro, probably alpha_2. The relevant code is missing, so we cannot test or know for sure.

      Best
      Daniel

      Comment


      • #4
        some of your locals are empty. So check that alpha_2, beta_2 and `x_beta' are non-empty.

        Comment


        • #5
          Perhaps the reason some or all of your locals are empty is that you wrote your code in the Do-file Editor window, but are submitting the lines of code by selecting a few at a time and running them, then selecting the next line(s) and running them, etc.. Unfortunately, to run a selection of lines Stata creates a temporary do-file containing the selected lines, so once that temporary do-file is finished, the local macros you defined within it vanish, because local macros are "local" to the do-file within which they are run.

          Comment


          • #6
            Actually this is my full code.

            I tried it again but still having the "+ invalid name"

            From not giving space between alpha_2 and beta_2 I tried to omit the "+"s.

            But it appeared there were "*T" is invalid.

            Hmm...

            How could I handle this issue?
            Attached Files

            Comment


            • #7
              You have come so very close to giving us what we need to help you, but then missed the final step.

              Please review the Statalist FAQ linked to from the top of the page, looking especially at sections 9-12 on how to best pose your question. You've already done the hard part, creating an example that reproduces your problem. But you provided a picture of your code, and Stata will not read a picture of code, and "I want to retype 27 lines of code from a picture" was said by nobody ever.

              So in particular, please read FAQ #12 and use CODE delimiters when posting code and results to Statalist.

              Added: Crossed with #8. Clyde apparently is the first person to say "I want to retype 27 lines of code from a picture." The only reason I was more patient than him was because my patience had not been tried by retyping 27 lines of code from a picture only to discover that it did not reproduce the problem.
              Last edited by William Lisowski; 17 Apr 2017, 19:08.

              Comment


              • #8
                First, don't EVER post code that you want people to work with as a screenshot again. There is no way to import code (nor data) from a screenshot--so you leave those who want to help you with no choice but to retype it keystroke by keystroke. On top of that, it sabotages your effort to get help because in this case, it is crucial to be certain that every character in the code is precisely what you have written. Being forced to retype your code, instead of copy/pasting it, I can never be certain that the code I tested is exactly the same as the code you are having problems. If you want to get help from this Forum you should invest some time reading the FAQ, especially #12, so as to understand what ways of showing code, data, and outputs are helpful, and which are not.

                With that behind us, I actually did retype your code. To the extent that I am confident (reasonably so) that my re-typed version is actually the same as yours, I can tell you that I cannot reproduce your difficulties: the code runs with no glitch up to the -medeff- command. I did not run the -medeff- command because it is not installed in my Stata. But you are claiming to have difficulties earlier in the code: I cannot reproduce them.

                The most likely explanation is the one that William Lisowski gave in #5. Did you read it? If so, read it again. If what he suggests is not the source of your problem, then your Stata installation must be somehow corrupted and you need to reinstall it. There is nothing wrong with the code.

                Added: Crossed with #7. William is more patient with you than I am!

                Comment

                Working...
                X