Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Maarten Buis <maartenlbuis@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: How to modify the contents of the [if] qualifier in ado files? |

Date |
Wed, 7 Dec 2011 16:17:00 +0100 |

I would not call the program test, as there is already an official command test in Stata, and having such a command around on your system can break the official command. I would not declare the frc option a string, but rather a integer. I would not use the loop to remove the unwanted observations but rather: sort `sample', stable replace `sample' = 0 in 1/`=_N-`frac'-1' This is probably faster and also solves your problem. You can preserve the sort order in your data (and that is a good idea) by adding the option -sortpreserve- to your -program-, see -help program-. Hope this helps, Maarten 2011/12/7 <Tomas.Konecny@cnb.cz>: > Hi, > I would like to write a short program that would reestimate a given regression with a smaller number of observations, where > the number of observations to be removed can be determined by a `frc' option. > > For now it looks like this: > > program test, nclass > version 9.2 > syntax anything [if] [in], frc(string) > > reg `anything' `if' `in' > > *mark the sample from previous regression > tempname sample > g `sample'=1 if e(sample) > > *mark observations from the end of the e(sample) that I want to exclude from the next estimation > replace `sample'=0 if `sample'[_n+1]==. & `sample'[_n-1]==1 & "`frc'"!="" > local i=2 > while `i'<=`frc' { > replace `sample'=0 if `sample'[_n+1]==0 > local i=`i'+1 > } > > *NOW HERE IS THE ACTUAL PROBLEM, I would like to have the `sample' selection criteria compatible with other possible [if] constraints, > *that is, I would like the program to run also cases like > > if "`if'"!="" { > local `if' "`if' & `sample'==0" > } > > reg `anything' `if' `in' > > end > > For example -> > > reg pd unempl if time>tq(1994q1), frc(2) > > The if "`if'"!="" {.... part onwards, however, does not work. > > Thank you very much for any advice, > > Tomas > Czech National Bank > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ -- -------------------------- Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany http://www.maartenbuis.nl -------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: How to modify the contents of the [if] qualifier in ado files?***From:*Tomas.Konecny@cnb.cz

- Prev by Date:
**st: RE: How to modify the contents of the [if] qualifier in ado files?** - Next by Date:
**Re: st: tabout and foreach -counter error** - Previous by thread:
**st: RE: How to modify the contents of the [if] qualifier in ado files?** - Next by thread:
**st: Re: St: Logistic regression & standardized coefficients; Multinomial GOF test** - Index(es):