I have an unbalanced panel of more than 3000 firms. The firms have been
assigned id from 1 to 3256.
I was wonderting if i could exclude some firms (say id 45 to 560) when
I run
any regression. How could I do so?
g want = ~ inrange(_n,45,560)
regress .... if want
Note that the ~ is NOT, so this is "I want those not in range 45, 560".
If you had more than one such range, define the dummies in terms of
those you do NOT want, add up those dummies, and NOT the result.
CORRECTION:
g nowant1 = inrange(_n,45,90)
g nowant2 = inrange(_n,101,120)
g nowant3 = inrange(_n,131,500)
g want = ~ (nowant1+nowant2+nowant3)
You could also do this with logical operators, as Neil suggests. If you
have a lot of logical conditions, my approach is perhaps clearer. Use
"generate byte" to create the dummies to reduce the overhead.