Statalist The Stata Listserver


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

st: local variables program


From   "Nachbar, Dirk" <[email protected]>
To   <[email protected]>
Subject   st: local variables program
Date   Mon, 25 Jun 2007 10:49:05 +0100

I want to run some regressions and have problems with the local and
global variables. I think Stata doesn't like the forval loop. How should
I refer to min and max? If you spot any other errors, it would be
appreciated.


local max=999999999999999999
sum  avgunitprice if id==5, detail
global min=r(p5)
global max=r(p95)
forval i= min min+(max-min)/100 to max {
gen belowprice=avgunitprice*(avgunitprice<`i')
gen below=(avgunitprice<`i')
gen aboveprice=avgunitprice*(avgunitprice>=`i')
gen above=(avgunitprice>=`i')
qui reg lunit below belowprice above aboveprice if id==5, nocons
if e(rmse)<max {
local max=e(rmse)
reg lunit below belowprice above aboveprice		
}
}

Dirk Nachbar


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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