Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: too many macros?!


From   Rufus Peabody <[email protected]>
To   [email protected]
Subject   st: too many macros?!
Date   Wed, 27 Aug 2008 22:55:47 -0700

I ran the following code, but got the error message "too many macros". What I'm trying to do is create a macro that includes the regressors to use for that specific time through the loop. It includes a different number of regressors each time. For each "tm_gmid_yr" I'm looping through, I want the regressors to be all lags possible within that year (by week--so L`i'., L`i+7'.,..., where i is based on the remainder when dividing "tm_gmid_yr" by 7 ). Anybody have any idea how to get around this problem?

local mark=mark
forvalues year=2000/2007 {
forvalues tm_gmid_yr=7/156 {
foreach v of local ratevars {
cap gen `v'_norm_pred=.
cap gen `v'_norm_pred2=.
tempvar pred1 pred2
local regressors "lweek_`v'_norm"
local x=mod(`mark',`tm_gmid_yr')
local regressors "`"`regressors' L`x'.lweek_`v'_norm"'"
local y=floor(mark/7)
while(`y'>=1) {
local num=(7*`y')+`x'
local regressors "`"`regressors' L`num'.lweek_`v'_norm"'"
local y=`y'-1
}
regress nweek_`v'_norm `regressors' if tm_gmid_yr<=tm_gmid_yr+7 & tm_gmid_yr>=tm_gmid_yr-7 & year<=`year'
predict `pred1' if year==`year' & tm_gmid_yr==`tm_gmid_yr'
regress nweek_`v'_norm `regressors' if year<=`year'
predict `pred2' if year==`year' & tm_gmid_yr==`tm_gmid_yr'
replace `v'_norm_pred=`pred1' if year==`year' & tm_gmid_yr==`tm_gmid_yr'
replace `v'_norm_pred2=`pred2' if year==`year' & tm_gmid_yr==`tm_gmid_yr'
drop `pred1' `pred2'
}
}
}
*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index