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: RE: How to modify the contents of the [if] qualifier in ado files?
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: How to modify the contents of the [if] qualifier in ado files?
Date
Wed, 7 Dec 2011 15:13:54 +0000
if "`if'"!="" {
local `if' "`if' & `sample'==0"
}
should probably be
if "`if'"!="" {
local if "`if' & `sample'==0"
}
else local if "if `sample' == 0"
where you didn't ask about the last bit, but I guess it's what you want.
Nick
[email protected]
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of [email protected]
Sent: 07 December 2011 14:33
To: [email protected]
Subject: st: How to modify the contents of the [if] qualifier in ado files?
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.
*
* 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/