Announcement

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

  • Problem with xi - syntax

    I just realized the solution. Sorry.

    When you are making only dummies with xi and not running a command, you do not need the ":".
    Last edited by Kyle Hood; 08 Apr 2020, 18:55.

  • #2
    You are using the xi: prefix, not the xi command. If you want to create indicators ("dummies") for the variable weekday, use the -xi- command:
    Code:
    xi weekday // NB no colon(:)
    When you use the -xi:- prefix (note the colon) Stata expects that to be followed by a command, not be a variable.

    That said, why are you doing this at all? It is rarely necessary or helpful to create indicator variables in Stata as the use of factor-variable notation (see -help fvvarlist-) works in nearly every Stata command where you can imagine it would be useful, and is simpler. If, for example, you are creating these indicators because you want to use them as variables in a regression, you don't need -xi- for that. You can just write
    Code:
    regress outcome_ variable i.weekday …
    The output you get from that will be better organized and easier to read than you would get with -xi-, and it will also make it possible for you to use the -margins- command following your estimation, which produces many important statistics.

    Comment


    • #3
      Clyde, I appreciate the reply. I couldn't figure it out because I had used the command so many times. But I finally decided to read the help more carefully, and I found this. I do wish it gave a more useful error message.

      Comment

      Working...
      X