Announcement

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

  • reghdfe / estfe: invalid syntax

    Dear all,

    when running the command estfe (belongs to reghdfe), Stata sometimes gives me the error message "invalid syntax". I use Stata 17.0.

    I run a fixed effects model using the reghdfe command by Sergio Correia (amazing command):
    Code:
    eststo column1: reghdfe stock_weight i.cat_distance##i.cat_disaster, absorb(year disaster_quarter num_county) vce(cluster county)
    eststo column2: reghdfe stock_weight i.cat_distance##i.cat_disaster `firmcontrols', absorb(year disaster_quarter num_county) vce(cluster county)
    To indicate the FE in my model, I use the estfe command:
    Code:
    estfe column*, labels(year "Year FE" disaster_quarter "Disaster quarter FE" num_county "County FE")
        return list
    Then, I export the obtained regression output using esttab:
    Code:
    esttab column1 column2 using "05_tables\table 11.rtf", nobaselevels interaction(" x ") indicate("Year FE=0.year" "Disaster quarter FE=0.disaster_quarter" "County FE=0.num_county") drop("0._cons") label replace
    Usually, the command runs without any error message and gives me the desired result.

    Sometimes, and only sometimes however, I get the error message "invalid syntax". I tried uninstalling and installing again the reghdfe, the estout and the erepost (necessary for estfe) packages, closening and opening Stata and restarting my laptop to solve the error. This works sometimes, however I cannot narrow down what exact measure fixes the issue.

    Does anybody know what is the cause for this error message? Do you also know how to fix this issue?

    Thanks in advance!


  • #2
    From my experience, it is invisible characters in the command line. Copying and pasting the command line from a text editor or a word processor may introduce invisible characters which appear to be spaces. Usually, I delete all spaces in the command line and create them again (within the do file or the command window), and this does the trick.

    Code:
    display "invisible`=uchar(160)'character"
    Res.:

    Code:
    . display "invisible`=uchar(160)'character"
    invisible character

    Comment


    • #3
      Andrew, thank you very much for your help.

      Indeed, I had copied and pasted parts of this code from another source. I now have replaced these pieces by self-written code and will observe if this solves the issue.

      Comment


      • #4
        I followed the recommendation by Andrew and it worked well for a few days. But now the issue returned and I do not know why. Does anybody have an idea?

        Comment

        Working...
        X