Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: How to modify the contents of the [if] qualifier in ado files?
From
[email protected]
To
<[email protected]>
Subject
st: How to modify the contents of the [if] qualifier in ado files?
Date
Wed, 7 Dec 2011 14:32:39 +0000
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/