Announcement

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

  • Help with 'not equal to' sign - invalid syntax error

    Hello, I am trying to create a new variable, let's say low-education, for those individuals who do not have a degree. When I use a standard command "gen low-edu=1 if high_qual!=1" the STATA gives "invalid syntax" error. I tried to use "~=" symbol instead to specify "not equal to", but I encounter the same problem. Is there anything else I can do?

  • #2
    The error lies elsewhere. low-edu is an illegal variable name. low_edu would be legal. If minuses were allowed in variable names, you would need quite different syntax to subtract one variable from another.

    Comment


    • #3
      Stata doesn't allow to specify variable with "-" symbol. Try instead
      Code:
      gen low_edu=1 if high_qual!=1

      Comment


      • #4
        Dear Nick Cox and Marco Errico, thank you so much!

        Comment

        Working...
        X