Dimitriy V. Masterov replied to Shuaizhang Feng:
> Your can use preserve/restore to do this:
> preserve
> keep if age<40
> reg ....
> restore
And Nick Cox replied to Shuaizhang Feng with:
> gen mysample = (age < 40) & (nobel_prize == 1) & (extrasensoryperception
> == 1)
>
> ...
>
> reg ... if mysample
>
> See also http://www.stata.com/support/faqs/data/trueorfalse.html
Running regressions using restricted samples (or by leaving out
disqualifying observations) is something I've been really keen to do for
quite some time. But solutions such as the ones above seem to be the only
ones available (but that doesn't mean to say that they're bad).
I'm not really one for adding to StataCorp's burden, for they probably
have enough to do in preparing for version 9. But wouldn't it be great if
one could run a regression in the following way:
. reg tomatoes potatoes onions sausages, suspendin(10 100 250)
so that you could simply suspend the observations without having to -drop-
them for that regression and then have to -restore- the dataset
afterwards? Desirably, this option would automatically pick up the
observation numbers as they appear by row in the data editor.
No doubt this idea will be shot down in myriad ways and people would say
that it couldn't work. But, to quote the British comedy duo Armstrong and
Miller, "Yes, but it would be good if it did."
CLIVE NICHOLAS |t: 0(044)191 222 5969
Politics |e: [email protected]
Newcastle University |http://www.ncl.ac.uk/geps
*
* 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/