Solved
Contributor
Posts: 30

# Moving or rolling skewness

Hi there,

I have a list of daily returns and i wanna compute the rolling skewness. What code can i use here to generate many values of skewness.. Take for instance the following data;

Date                Returns

 25/03/2013 0.8 26/03/2013 0.83 27/03/2013 0.82 28/03/2013 0.83 29/03/2013 0.83 01/04/2013 0.83 02/04/2013 0.83 03/04/2013 0.81 04/04/2013 0.81 05/04/2013 0.77 08/04/2013 0.79 09/04/2013 0.77 10/04/2013 0.77 11/04/2013 0.79 12/04/2013 0.78 15/04/2013 0.76 16/04/2013 0.77 17/04/2013 0.77

Accepted Solutions
Solution
‎04-04-2015 11:22 AM
Super User
Posts: 10,766

## Re: Moving or rolling skewness

OK . Here is .

```data have;
input Date  : ddmmyy10.            Returns ;
format date ddmmyy10.;
cards;
25/03/2013     0.8
26/03/2013     0.83
27/03/2013     0.82
28/03/2013     0.83
29/03/2013     0.83
01/04/2013     0.83
02/04/2013     0.83
03/04/2013     0.81
04/04/2013     0.81
05/04/2013     0.77
08/04/2013     0.79
09/04/2013     0.77
10/04/2013     0.77
11/04/2013     0.79
12/04/2013     0.78
15/04/2013     0.76
16/04/2013     0.77
17/04/2013     0.77
;
run;

proc summary data=have  nway;
class      date  ;
format date monyy7.;
var returns;
output out=want skewness=skewness;
run;
```

Xia Keshan

All Replies
Super User
Posts: 10,766

## Re: Moving or rolling skewness

What is the window length of rolling skewness ? a month , a year ?

Contributor
Posts: 30

## Re: Moving or rolling skewness

The window length is a month

Super User
Posts: 10,766

## Re: Moving or rolling skewness

For a day you want a previous month's skewness or a next month's ?

And the window length should be the exact integer , a month could have 30 days 31 days .

And better post the output you want according to your sample data .

Message was edited by: xia keshan

Contributor
Posts: 30

## Re: Moving or rolling skewness

Sorry just to clarify i have monthly data. So i want to find out skewness this month and last month

Super User
Posts: 23,663

## Re: Moving or rolling skewness

Do you have proc expand? Though your question doesn't appear to be a rolling window but a simple aggregation, how to calculate skewness from daily data for a months worth of data.

Contributor
Posts: 30

## Re: Moving or rolling skewness

Hi Reeza. Here is my interpretation for the Skewness i am trying to calculate.

"SKEW is the third standardized moment of return of the past 22 trading days". So meaning i have daily data for a given month and Ticker. So i want to find the skewness for each month for each ticker in each year.

Super User
Posts: 23,663

## Re: Moving or rolling skewness

I understand the definition of skewness. It isn't a moving or rolling calculation. In moving/rolling calculations the periods overlap. You appear to have distinct periods.

At any rate, you have the correct answer above from Xia.

Contributor
Posts: 30

## Re: Moving or rolling skewness

Thanks Reeza.Oh yes i had confused it as moving/trailing. I got it now. Thanks @Keshan too.

Solution
‎04-04-2015 11:22 AM
Super User
Posts: 10,766

## Re: Moving or rolling skewness

OK . Here is .

```data have;
input Date  : ddmmyy10.            Returns ;
format date ddmmyy10.;
cards;
25/03/2013     0.8
26/03/2013     0.83
27/03/2013     0.82
28/03/2013     0.83
29/03/2013     0.83
01/04/2013     0.83
02/04/2013     0.83
03/04/2013     0.81
04/04/2013     0.81
05/04/2013     0.77
08/04/2013     0.79
09/04/2013     0.77
10/04/2013     0.77
11/04/2013     0.79
12/04/2013     0.78
15/04/2013     0.76
16/04/2013     0.77
17/04/2013     0.77
;
run;

proc summary data=have  nway;
class      date  ;
format date monyy7.;
var returns;
output out=want skewness=skewness;
run;
```

Xia Keshan

🔒 This topic is solved and locked.