<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do I calculate cumulative returns for multiple different time periods? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743584#M232839</link>
    <description>&lt;P&gt;Hey Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now I am using SAS studio.&lt;/P&gt;&lt;P&gt;As for my calculation, right now I have daily stock return data. But I want to calculate the return for a 6 month holding period starting from the transaction date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 May 2021 15:33:34 GMT</pubDate>
    <dc:creator>Mistletoad</dc:creator>
    <dc:date>2021-05-25T15:33:34Z</dc:date>
    <item>
      <title>How do I calculate cumulative returns for multiple different time periods?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743581#M232836</link>
      <description>&lt;P&gt;I am trying to calculate the cumulative returns for multiple different 6 month periods for a market index.&lt;/P&gt;&lt;P&gt;In my first table, I have the daily returns for an index.&lt;/P&gt;&lt;PRE&gt;         date          daily return

1	19251231	.	
2	19260102	0.005689	
3	19260104	0.000706	
4	19260105	-0.004821	
5	19260106	-0.000423	
6	19260107	0.004988	
7	19260108	-0.003238	&lt;/PRE&gt;&lt;P&gt;In my second table, I have a list of transaction dates. Each transaction date is the start_date and the end date is 6 months after the start date.&lt;/P&gt;&lt;P&gt;I would like to calculate the 6 month cumulative returns for all these different transaction dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        Filing identifier       Transaction Date
1	0000897069-07-000506	02/15/2007	
2	0000897069-07-000606	02/20/2007	
3	0000897069-07-000757	03/07/2007	
4	0000897069-07-000745	03/07/2007	
5	0000897069-07-000750	03/07/2007	
6	0000897069-07-000753	03/07/2007	
7	0000897069-07-000747	03/07/2007	
8	0000897069-07-001409	06/13/2007	
9	0000897069-07-001417	06/14/2007&lt;/PRE&gt;&lt;P&gt;I have been using the following equation to calculate cumulative returns&lt;/P&gt;&lt;PRE&gt;exp(sum(log(1+a.vwretd))) - 1 as cum_return&lt;/PRE&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 15:21:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743581#M232836</guid>
      <dc:creator>Mistletoad</dc:creator>
      <dc:date>2021-05-25T15:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I calculate cumulative returns for multiple different time periods?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743583#M232838</link>
      <description>Do you have SAS/ETS licensed? If so, look into PROC EXPAND. &lt;BR /&gt;&lt;BR /&gt;Can you expand on your calculation, are you just using the value from 6 months later to get the return?&lt;BR /&gt;Is it rolling? Not sure what exactly you mean by cumulative here...</description>
      <pubDate>Tue, 25 May 2021 15:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743583#M232838</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-25T15:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I calculate cumulative returns for multiple different time periods?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743584#M232839</link>
      <description>&lt;P&gt;Hey Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now I am using SAS studio.&lt;/P&gt;&lt;P&gt;As for my calculation, right now I have daily stock return data. But I want to calculate the return for a 6 month holding period starting from the transaction date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 15:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743584#M232839</guid>
      <dc:creator>Mistletoad</dc:creator>
      <dc:date>2021-05-25T15:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I calculate cumulative returns for multiple different time periods?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743594#M232844</link>
      <description>Is that taking the first date from the 6 month interval and the last or are you accounting for every day? What about holidays? What about weekends? How are those factored in?</description>
      <pubDate>Tue, 25 May 2021 15:59:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743594#M232844</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-25T15:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I calculate cumulative returns for multiple different time periods?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743669#M232878</link>
      <description>&lt;P&gt;Make a series of daily cumulative returns (plus 1) for the entire history of the index.&amp;nbsp; Put it in an array indexed by date (array cumret_plus1_hist below).&amp;nbsp; Fill missing dates with the most recent prior cumulative return (plus 1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then a 6-month forward-looking cumulative return is&amp;nbsp; a simple calculation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;cumret_plus1(6 months forward) / cumret_plus1(transaction date)&amp;nbsp; &amp;nbsp;- 1&lt;/STRONG&gt;&lt;/EM&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is an untested program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let begdate=31dec1925;
%let enddate=31dec2020;
data want (drop=vwretd date _:);
  if _n_=1 then do;
    array cumret_plus1_hist{%sysevalf("&amp;amp;begdate"d):%sysevalf("&amp;amp;enddate"d)} _temporary_;
    _cumret_plus1=1;   /* initialize to cumret=0 */

    /* Populate the array */
    do until (end_of_index);
      set index end=end_of_index;
      _cumret_plus1=_cumret_plus1 * (1+vwretd);
      cumret_plus1_hist{date}=_cumret_plus1;
    end;
    /* Carry forward to any dates with missing vwretd */
    do _d="&amp;amp;begdate"d to "&amp;amp;enddate"d;
      if cumret_plus1_hist{_d}=. then cumret_plus1_hist{_d}=cumret_plus1_hist{_d-1};
    end;
  end;

  set transactions;

  _d=intnx('month',transaction_date,6,'same');
  cumret=   cumret_plus1_hist{d}/cumret_plus1_hist{transaction_date} - 1;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This program assumes the data set INDEX is in chronological order.&amp;nbsp; But the transaction file can be in any order.&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 19:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-calculate-cumulative-returns-for-multiple-different/m-p/743669#M232878</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-05-25T19:01:55Z</dc:date>
    </item>
  </channel>
</rss>

