I have data of daily returns for several stocks. This is what my data looks like (simplified): PERMNO DATE RETURN 10078 2010JAN02 0.0500 10104 2010JAN02 -0.0190 10107 2010JAN02 0.0020 10078 2010JAN03 0.0040 10104 2010JAN03 -0.0400 10107 2010JAN03 0.0500 ... ... ... 10078 2015JAN02 -0.0190 10104 2015JAN02 0.0100 10107 2015JAN02 0.0700 10078 2015JAN05 0.0500 10104 2010JAN03 -0.0190 10107 2010JAN03 0.0020 PERMNO identifies a stock, DATE identifies a date (yyyymmmdd), RETURN is the daily stock return. I have simplified this example for only three stocks (10078, 10104, 10107). Goal: I am trying to calculate rolling skewness for each stock i in a given month t. I want to calculate the monthly skewness measure for each stock using the previous 6 months (i.e. months t-6 to t-1) of daily returns data. Therefore, for a stock in e.g. July 2010, I want the skewness measure for that month to be based on its daily returns from January 2010 to June 2010. I want the output data to include PERMNO, month ID, and the monthly skewness measure (based on prior 6 months of data) for that month. Here is a a picture to illustrate the desired output I want: PERMNO DATE 6MONTH_SKEWNESS 10078 2010JUL30 0.7257 10104 2010JUL30 -0.7056 10107 2010JUL30 -0.6781 10078 2010AUG31 0.9999 10104 2010AUG31 -0.6719 10107 2010AUG31 -0.7056 ... ... ... 10078 2015JUL30 -0.1651 10104 2015JUL30 0.1056 10107 2015JUL30 0.6181 10078 2015AUG31 -0.8886 10104 2015AUG31 0.6119 10107 2015AUG31 0.1056 I have searched the web extensively and tried this myself, but I feel really stuck on this problem. Thank you in advance for anyone who is able to help in any way.
... View more