BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
amanda_cz
Calcite | Level 5

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

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

View solution in original post

2 REPLIES 2
Haikuo
Onyx | Level 15

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 4945 views
  • 0 likes
  • 2 in conversation