Announcement

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

  • Error 198 Invalid Name (Beginner)

    I am only a beginner at using Stata and have been given the following error:

    reg DY_AS30 L(1).DY_AS30 L(1).R_AS30 if yw(2007w1,2015w52)
    2015w52 invalid name
    r(198);

    DY_AS30 and R_AS30 are my variable, and yw is my time variable

    Please help, Thanks

  • #2
    Well, your syntax is mangled, and, to be honest, I can't tell what it is you were trying to do, so I can't suggest a correction.

    yw() is the name of a built-in Stata function. So by using yw(...) you have led Stata to expect that what is inside the parentheses will be the arguments of the yw() function, which happens to be a pair of integers separated by a comma. Now 2015w52 is not an integer in its own right. Having recognized that, Stata wonders whether perhaps it might be the name of an integer variable. But 2015w52 is also not a valid variable name. Since either literal integers or names of variables containing integers are the only allowable arguments for the yw() function, Stata gives up.

    So the first thing you have to do is rename your yw variable to something that is not already a Stata command name or function name. You might consider, for example, year_week, or ywk or something like that.

    That said, the syntax -if ywk(2017w1, 2015w52)- isn't going to fly either because variable names followed by parenthesized expressions are not valid syntax either.

    I'm going to speculate that what you want to do is restrict your regression to those observation where your variable yw (which I'm going to treat as having been renamed to year_week) is between 2017w1 and 2015w52, inclusive. In that case, the syntax is:

    Code:
    reg DY_AS30 L(1).DY_AS30 L(1).R_AS30 if inrange(year_week, tw(2007w1), tw(2015w52))

    Comment


    • #3
      Thank You very much I was able to solve it.

      Cheers

      Comment


      • #4
        Hi All, I'm beginner and i want to pull dates >= but I get this error "list pid_hhvlog hh_mem_hhvlog v1_date_hhvlog if v1_date_hhvlog >=20jun2016
        20jun2016 invalid name
        r(198);

        Comment


        • #5
          Possibly

          Code:
          if v1_date_hhvlog >= td(20jun2016)

          Comment

          Working...
          X