Statalist


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

st: RE: AW: How to adjust the content of a local macro?


From   Joachim Landström <joachim.landstrom@fek.uu.se>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: AW: How to adjust the content of a local macro?
Date   Wed, 9 Dec 2009 16:04:23 +0100

It's so simple - when you know where to look. 

Thank you Martin.

/Joachim

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
Sent: Wednesday, December 09, 2009 3:49 PM
To: statalist@hsphsun2.harvard.edu
Subject: 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: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Joachim
Landström
Gesendet: Mittwoch, 9. Dezember 2009 15:51
An: statalist@hsphsun2.harvard.edu
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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index