Dear Reeza,
Thanks. YEs, I have SAS license and I used it to calculate volatility. But the problem is that it calculates based on past 12 observations instead of just past 12 months. For example, if one month is missing in past 12 months period i.e., July is missing from January to December 1985 then it will use monthly return from December 1984 too. I am using teh following code in SAS:
Data ret; infile 'D:\My SAS Files\9.4\US\US paper data\ret.dat'; Input stock $1-5 date1 $7-14 exc $16-17 sharecode $19-20 ret; run; data ret1; set ret; if sharecode^=10 and sharecode^=11 then delete; date=SUBSTRN(date1,1,6); year= SUBSTRN(date1,1,4); month= SUBSTRN(date1,5,2); run; data have(keep=stock ret monthDate); set ret1; monthDate = mdy(month, 1, year); if ret=-66 then delete; if ret=-77 then delete; if ret=-88 then delete; if ret=-99 then delete; if ret=. then delete; run; proc sql; create table roll as select h2.stock, h2.monthDate as periodEndDate format=yymmd7., h2.ret, mean(h1.ret) as meanRet, std(h1.ret) as stdRet from have as h1 inner join have as h2 on h1.stock=h2.stock and intck("MONTH", h1.monthDate, h2.monthDate) between 0 and 11 group by h2.stock, h2.monthDate, h2.ret having count(h2.stock)=12; quit;
... View more