Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: balanced sub-panel to test for selection bias

From   Kit Baum <>
Subject   st: re: balanced sub-panel to test for selection bias
Date   Thu, 24 May 2007 07:53:30 -0400

sacrificial samovar

Olga wrote

Thank you very much for your help, but last command
results in removing
ALL my observations. Maybe I am doing smth wrong?

egen nfarm = count(farm),by(year)
summarize nfarm, meanonly
by year: keep if nfarm == `r(max)'

Yes, you must be doing something wrong (perhaps mangling the punctuation around r(max)?) as it must be true that at least one farm has the maximum number of observations signalled by the summarize command. Try putting in

tab nfarm

after the summarize and see what the distribution of the count is in your sample. I tried this with a hacked version of the Grunfeld data and it worked fine. Then take out the -tab- and try the lines above exactly as punctuated.

Kit Baum, Boston College Economics and DIW Berlin
An Introduction to Modern Econometrics Using Stata:

* For searches and help try:

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