Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: excluding some cases (correction)


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: excluding some cases (correction)
Date   Mon, 25 Jul 2005 08:37:14 -0400

Alice said

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.

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index