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

Hi guys. 


I am having a problem with calculating rolling window cumulative returns. 

I have a panel data set with daily returns of approximately 40 different companies and 8 years of data. None of the companies have the same inception date. 

 

I would like to create a variable that shows the moving cumulative returns for the past 36 month for each company. If the company has not been in the sample for 36 months it should just be the cumulative return for total period the company has been the data set. Once it reaches 36 month of data, it should start calculating a rolling 36 month (750 business day) cumulative return.

 

I have no problem calulating a variable with a return series since inception. But I have trouble, when the base date has to move one day forward in time. 

 

My data looks like this: 

 

Data=Rolling: 

date                     firm                retun (daily)

1/1/2010                a                      4%

1/2/2010                a                      3%

.

.

1/1/2010                b                       1%

1/2/2010                b                      -2%  

.

.

04/24/2015            c                       3% 

04/25/2015            c                      -5%

 

 

Do you guys have any suggestions how to creating a variable with a rolling compounded cumulative return series with a window size of 36 month (approximately 750 week days of observations)? I would have to do a graph, when the variable has been created, but that shold not be a problem. 

 

I really hope you can help, 


best, Joe. 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

PROC EXPAND let's you calculate a rolling N month cumulative product. That sounds exactly like what you want.

--
Paige Miller

View solution in original post

4 REPLIES 4
JoeBill
Fluorite | Level 6

I would have loved that to work, but it is not a moving average, but a moving compoundig of the return that I am looking for :/... 

PaigeMiller
Diamond | Level 26

PROC EXPAND let's you calculate a rolling N month cumulative product. That sounds exactly like what you want.

--
Paige Miller
JoeBill
Fluorite | Level 6

Proc expand using 'movprod [Window]' did the job! Thanks 🙂 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 4 replies
  • 2667 views
  • 2 likes
  • 3 in conversation