## How to calculate annual compounding returns based on monthly return data

Solved
Occasional Contributor
Posts: 10

# How to calculate annual compounding returns based on monthly return data

Currently I have multiple years' data for multiple firms of the monthly stock returns.

Firm_IDyearmonthreturn
101200210.05
...
1012014120.03
102200310.035
...
1022007120.045
.....
205200410.065
...

If I calculate it by hand then:

annual compounding return=(1+ Ret_month1)*(1+Ret_month2)*(1+Ret_month3)*...*(1+Ret_month11)*(1+Ret_month12)

However, I don't know how to write a sas program to do this  Any suggestions?

Accepted Solutions
Solution
‎08-18-2014 10:28 PM
Posts: 3,167

## Re: How to calculate annual compounding returns based on monthly return data

Not tested:

data want;

do until (last.year);

set have;

by firm_id year;

if first.year then

compound_ret=1;

compound_ret=compound_ret*(1+return);

end;

run;

Haikuo

All Replies
Solution
‎08-18-2014 10:28 PM
Posts: 3,167

## Re: How to calculate annual compounding returns based on monthly return data

Not tested:

data want;

do until (last.year);

set have;

by firm_id year;

if first.year then

compound_ret=1;

compound_ret=compound_ret*(1+return);

end;

run;

Haikuo

Occasional Contributor
Posts: 10

## Re: How to calculate annual compounding returns based on monthly return data

Thanks. It works!

🔒 This topic is solved and locked.