<?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: Cumulative Returns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Returns/m-p/312729#M312953</link>
    <description>&lt;P&gt;Add to your data, according to dates, a period code as new variable (the &lt;STRONG&gt;fiscal_year&lt;/STRONG&gt;),&lt;/P&gt;
&lt;P&gt;then run your SQL with a light change:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;/*&amp;nbsp;&lt;SPAN&gt;where ('01apr1991'd &amp;lt;= date &amp;lt;= '31mar1992'd) &amp;lt;&amp;lt;&amp;lt; drop this line */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;group by fiscal_year, permno&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Nov 2016 20:49:34 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2016-11-18T20:49:34Z</dc:date>
    <item>
      <title>Cumulative Returns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Returns/m-p/312723#M312952</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the below SAS code for calculating cumulative returns. The code works fine for one period but I need to get it worked for multiple periods.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table returns as&lt;BR /&gt;select *&lt;BR /&gt;from amirkhan.mydata&lt;BR /&gt;order by permno, date&lt;BR /&gt;;&lt;BR /&gt;create table cum_returns as&lt;BR /&gt;select permno , exp(sum(log(1+ret))) - 1 as cum_return&lt;BR /&gt;, min(ret) as minret , max(ret) as maxret&lt;BR /&gt;, n(ret) as n_periods , nmiss(ret) as n_miss&lt;BR /&gt;, sum(ret=.P) as n_dot_p , min(date) as first_date&lt;BR /&gt;, max(date) as last_date&lt;BR /&gt;from returns&lt;BR /&gt;where ('01apr1991'd &amp;lt;= date &amp;lt;= '31mar1992'd)&lt;BR /&gt;group by permno&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code generates the cumulative returns for the period April 01, 1991 to March 31, 1992. I need to modify the code so that it could give me the results for multiple periods. I&amp;nbsp;need cumulative returns for the following periods as well:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;April 01, 1992 to March 31, 1993&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;April 01, 1993 to March 31, 1994&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;April 01, 1994 to March 31, 1995&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for your time and help.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 20:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Returns/m-p/312723#M312952</guid>
      <dc:creator>AmirSari</dc:creator>
      <dc:date>2016-11-18T20:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Returns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Returns/m-p/312729#M312953</link>
      <description>&lt;P&gt;Add to your data, according to dates, a period code as new variable (the &lt;STRONG&gt;fiscal_year&lt;/STRONG&gt;),&lt;/P&gt;
&lt;P&gt;then run your SQL with a light change:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;/*&amp;nbsp;&lt;SPAN&gt;where ('01apr1991'd &amp;lt;= date &amp;lt;= '31mar1992'd) &amp;lt;&amp;lt;&amp;lt; drop this line */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;group by fiscal_year, permno&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 20:49:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Returns/m-p/312729#M312953</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-18T20:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative Returns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-Returns/m-p/312740#M312954</link>
      <description>Thank you for your reply!&lt;BR /&gt;That solved the problem!</description>
      <pubDate>Fri, 18 Nov 2016 21:43:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-Returns/m-p/312740#M312954</guid>
      <dc:creator>AmirSari</dc:creator>
      <dc:date>2016-11-18T21:43:50Z</dc:date>
    </item>
  </channel>
</rss>

