Announcement

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

  • nothing found where subexp expected for bysort : xtreg with if condition

    Hi
    I am new to STATA. I want to do xtreg with if condition and use tertile for bysort for my unbalanced panel data.

    Example :
    id time S y x
    1 1 1 10 20
    1 2 1 9 50
    1 3 1 4 80
    2 1 0 5 66
    2 2 0 3 71
    3 1 1 11 89
    4 1 0 15 10
    4 2 0 18 35
    4 3 0 20 22
    4 4 0 9 98
    4 5 0 8 100
    code:

    xtset id time
    gen x_lag1=l1.x
    egen x_rank=rank(x_lag1), by(time) unique
    replace x_rank=x_rank/_n
    xtile tertile= -x_rank , n(3)

    bysort tertile : asdoc xtreg y x if S==1 , fe vce(robust) nest reset (I also try " bysort tertile (S) : asdoc xtreg y x1 x2 if S==1 , fe vce(robust) nest reset ")

    error:
    invalid syntax
    invalid syntax
    invalid syntax
    nothing found where subexp expected
    r(3000);

    Could you please suggest to me how should I do?
    Thanks in advance
Working...
X