<>
To illustrate:
*************
clear*
set obs 10
gen byte id=_n
levelsof id, local(panelVar)
di in r "Contents of local panelVar: `panelVar'"
loc newpanelVar="`panelVar'"
di in r "Contents of local newpanelVar: `newpanelVar'"
foreach lev of local panelVar{
di in r "Contents of newpanelVar: `newpanelVar'"
local newpanelVar: list newpanelVar-lev
}
*************
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Martin Weiss
Gesendet: Mittwoch, 9. Dezember 2009 15:49
An: [email protected]
Betreff: st: AW: How to adjust the content of a local macro?
<>
Use the "{local | global} macname : list macname - macname" syntax in -help
macrolists-
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Joachim
Landström
Gesendet: Mittwoch, 9. Dezember 2009 15:51
An: [email protected]
Betreff: st: How to adjust the content of a local macro?
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/
*
* 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/
*
* 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/