Dear Stata users,
I have what I hope to be a minor problem that I nevertheless fail to find a
solution to. Suppose that I have a local macro panelVar that contains panel
ids. Based on a selection criterion I wish to remove some panel ids from
panelVar. How do I do that? I use Stata/MP 10.1 in Windows XP 32-bit.
More specifically see example below. Suppose the panel id is called id and
the time series variable is date. Per id & date I have the actual content in
the form of totalReturn (tDelta is 7):
**** Begin Example ****
local estimationPeriod = 3
local requiredEstimationPeriod = `estimationPeriod' * floor( 365 /
``tDelta'' )
levelsof id, local(panelVar)
preserve
quietly foreach i of local panelVar ///
{
restore, preserve
drop if id != `i'
summarize date if totalReturn != .
local `minDate' = r(min)
local `maxDate' = r(max)
summarize totalReturn if totalReturn != . ///
& date >= ``minDate'' & date <=
``maxDate''
if `r(N)' < `requiredEstimationPeriod' ///
{
***** Here I wish to update the local macro panelVar
such `i' is removed *********
}
else ///
{
}
}
**** End Example ****
*
* 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/