How can I regress several cross-sections, predict the values by year and
amend them into the main dataset?
I have an unbalanced panel and I want to run a regression for each year:
bys year reg y x
The point is to save the y-hat (predicted values) emanated from the year by
year regressions into a single column. I tried the -foreach- command put
apparently there is a problem with the syntax:
foreach num of local year {
reg y(num) x
predict y(num)
}
Many thanks,
Rafa
*
* 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/