Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Reese Andorfer <reese.and89@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | st: Regression and Looping |
Date | Sun, 2 Mar 2014 22:58:14 +0000 |
Dear all, I have an industry portfolio with at the respective return return_p and then I the return of the market portfolio return_m. My time period is 10 years and I have the returns- on a monthly basis. Now I would like to perform the following regression : reg return_p return_m for every month in my 10 year time period. I would like to save the constant as well as the beta coefficient for return_m, thus I tried to use the following : gen ID=string( dt) gen a0=. gen a1=. levelsof ID, local(x) foreach obs of local x { reg return_p return_m if ID=="`obs'" replace a0=_b[_cons] if ID=="`obs'" replace a1=_b[return_m] if ID=="`obs'" } whereby ID - is the date of the observation f.e. 01Jan03 in string form now I have no missing observations whatsoever and I get the error no observations. I would be very grateful if someone knows what I'm doing wrong here. Thank you, Best Reese * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/