Dear statlist users,
I want to compute moving average industry return and standard deviation over past 30 days for each date. My data is as follow:
date, ret (daily CRSP returns), industry (2-digit SIC)
It's not a panel because I have more observations for each date and industry. I've tried Clyde's loop in post:
http://www.statalist.org/forums/foru...60#post1180160
I modified the loop for my data (see attachment) but it's not working.

Stata is not returning any error (in a second I have a massage: end of do-file), but the loop is not working. It's large database (daily returns for 15 years).
Please also advice me for computation of the standard deviation.
Thank you in advance
Biljana
I want to compute moving average industry return and standard deviation over past 30 days for each date. My data is as follow:
date, ret (daily CRSP returns), industry (2-digit SIC)
It's not a panel because I have more observations for each date and industry. I've tried Clyde's loop in post:
http://www.statalist.org/forums/foru...60#post1180160
I modified the loop for my data (see attachment) but it's not working.
Stata is not returning any error (in a second I have a massage: end of do-file), but the loop is not working. It's large database (daily returns for 15 years).
Please also advice me for computation of the standard deviation.
Thank you in advance
Biljana
Comment