<?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 Cumulative returns from Event Study output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-returns-from-Event-Study-output/m-p/596121#M171592</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;This is probably a very novice question. I've tried several methods I've found by reading previous threads but none has worked so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset of abnormal returns from -10 days to +10 days around an event study (dataset named firm_level_results). These 135 companies are organized by PERMNO. I am trying to create an output table with cumulative results for each company in five different trading day windows (-1 to 0; 1- to 1; 0 to 1; 0 to 2; 0 to 5). Here is a screenshot of the dataset, EVTTIME is the trading day reference to the event date; ABRET is each day's abnormal return.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33114i0B3939A4CCFA99D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* I have previous code steps SQL combining several tables for regression controls*/

/*Calculate CARs for each company for each trading window*/

data temp.car_windows; set temp.car_windows; /* Create CAR results table */
run;

data temp.firm_level_results; set temp.firm_level_results; /* Source event data */

data want;
set temp.firm_level_results;
where evttime =&amp;gt; -1 and evttime &amp;lt;= 0; /* First trading window wanted */

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I realize this code is clunky, I was trying to figure out the first step before expanding into summing the results, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for whatever help someone can provide&lt;/P&gt;</description>
    <pubDate>Sun, 13 Oct 2019 22:13:24 GMT</pubDate>
    <dc:creator>Tango_Mike</dc:creator>
    <dc:date>2019-10-13T22:13:24Z</dc:date>
    <item>
      <title>Cumulative returns from Event Study output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-returns-from-Event-Study-output/m-p/596121#M171592</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;This is probably a very novice question. I've tried several methods I've found by reading previous threads but none has worked so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset of abnormal returns from -10 days to +10 days around an event study (dataset named firm_level_results). These 135 companies are organized by PERMNO. I am trying to create an output table with cumulative results for each company in five different trading day windows (-1 to 0; 1- to 1; 0 to 1; 0 to 2; 0 to 5). Here is a screenshot of the dataset, EVTTIME is the trading day reference to the event date; ABRET is each day's abnormal return.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33114i0B3939A4CCFA99D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* I have previous code steps SQL combining several tables for regression controls*/

/*Calculate CARs for each company for each trading window*/

data temp.car_windows; set temp.car_windows; /* Create CAR results table */
run;

data temp.firm_level_results; set temp.firm_level_results; /* Source event data */

data want;
set temp.firm_level_results;
where evttime =&amp;gt; -1 and evttime &amp;lt;= 0; /* First trading window wanted */

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I realize this code is clunky, I was trying to figure out the first step before expanding into summing the results, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for whatever help someone can provide&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 22:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-returns-from-Event-Study-output/m-p/596121#M171592</guid>
      <dc:creator>Tango_Mike</dc:creator>
      <dc:date>2019-10-13T22:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative returns from Event Study output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-returns-from-Event-Study-output/m-p/596128#M171595</link>
      <description>&lt;P&gt;Editted note:&amp;nbsp; Mistake!&amp;nbsp; Mistake!&amp;nbsp; Mistake!&amp;nbsp; The CAR's starting in event date zero should be this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  car_0_1  = (1+daily_car{1})/(1+daily_car{-1})-1;   * for (0,1);
  car_0_2  = (1+daily_car{2})/(1+daily_car{-1})-1;   * for (0,2);
  car_0_5  = (1+daily_car{5})/(1+daily_car{-1})-1;   * for (0,5);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The specified CAR's should, I believe be calculated like this:\&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So do you want 1 record per event with identifiers and 5 cumulative return variables corresponding to the five event-related periods you identify?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, assuming your data are sorted by permno/evtdate/evttime, then you can do something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data selected_cum_ar (drop=abret date ret);
  set have;
  by permno evtdate;
  where evttime between -1 and 5;
  array daily_car {-1:5} _temporary_;
  if first.evtdate then do;
    call missing (of daily_car{*});
    daily_car{evttime}=abret;
  end;
  else daily_car{evttime}= (1+daily_car(evttime-1))*(1+abret)-1;
  if last.evtdate;
  car_m1_0 = daily_car{0};  * for (-1,0);
  car_m1_1 = daily_car{1};  * for (-1,1);
&lt;STRIKE&gt;  car_0_1  = daily_car{1}/daily_car{-1};   * for (0,1);
  car_0_2  = daily_car{2}/daily_car{-1};   * for (0,2);
  car_0_5  = daily_car{5}/daily_car{-1};   * for (0,5);
&lt;/STRIKE&gt;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The WHERE filter only keeps trading day -1 through +5;&lt;/LI&gt;
&lt;LI&gt;The array "daily_car" will hold cumulative abnormal returns for -1, 0, 1, 2, ... through +5. &amp;nbsp; As a _temporary_ array it (a) won't be written to the output dataset, and (b) will not have values automatically reset to missing - a handy feature for building today's CAR using today's abret and the preceding CAR.&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp;The BY statement tells sas to expect the data in HAVE to be sorted, and provides automatic dummy variables letting you know if the record-in-hand is the beginning (or ending) of a set of records for a given permno/evtdate.&lt;/LI&gt;
&lt;LI&gt;&amp;nbsp; The "if last.evtdate" is a filter, allowing the subsequent production of your desired CARs only when the group of records is exhausted.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 14 Oct 2019 00:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-returns-from-Event-Study-output/m-p/596128#M171595</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-14T00:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative returns from Event Study output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cumulative-returns-from-Event-Study-output/m-p/596130#M171597</link>
      <description>&lt;P&gt;That is excellent, thank you very much for the code and the explanation&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 23:58:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cumulative-returns-from-Event-Study-output/m-p/596130#M171597</guid>
      <dc:creator>Tango_Mike</dc:creator>
      <dc:date>2019-10-13T23:58:54Z</dc:date>
    </item>
  </channel>
</rss>

