<?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: Problem Momentum strategy in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Problem-Momentum-strategy/m-p/643188#M3831</link>
    <description>&lt;P&gt;If the formation window is t-12 through t-2 (an eleven month window), shouldn't your criterion be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where a.permno=b.permno and &amp;amp;K&amp;lt; intck("month", b.date, a.date) &amp;lt;=&amp;amp;J&lt;BR /&gt;...&lt;BR /&gt;having&amp;nbsp;count(b.ret)&amp;nbsp;=&amp;nbsp;%eval(&amp;amp;J-&amp;amp;K)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I take K is the size of the gap (in months) between the end of the formation window and the current date.&amp;nbsp; I.e. with J=12 and K=1, then&amp;nbsp; to form a window in December, use the months of then prior December through current October.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the macro function %eval(&amp;amp;J=&amp;amp;K) to generalize the program.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Apr 2020 03:53:07 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2020-04-27T03:53:07Z</dc:date>
    <item>
      <title>Problem Momentum strategy</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Problem-Momentum-strategy/m-p/643048#M3830</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to replicate the Momentum Strategy where the formation window for my portfolios is&amp;nbsp; "t-12" -"t-2". That means that every month I have to find the stocks with the highest(lowest) cumulative returns ( during the past 12 months) and allocate them into different buckets. The formation period is from t-12 to t-2 since I need to skip one month.&amp;nbsp; The following code is meant to help with this, but I dont see intck statement skipping 1 month. I addition to this, when I constrcut the weights and the returns of the portfolios I get the opposite results of a&amp;nbsp; momentum strategy.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any comments would be much appreciated.&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;let %J= 12&lt;/P&gt;&lt;P&gt;let % K= 1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;/* Creating momentum measures based on past 12 (J) Month Compounded Returns*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create table umd&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;as select distinct a.permno, a.date,a.Mkcap, exp(sum(log(1+b.ret))) - 1 as cum_return&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from msex2 (keep=permno date MKcap) as a, msex2 as b&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where a.permno=b.permno and 0&amp;lt;= intck("month", b.date, a.date) &amp;lt;&amp;amp;J&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;group by a.permno, a.date&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;having count(b.ret)=&amp;amp;J;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit; * Keep stocks with available return info in the formation period;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;proc sort data=umd; by date; run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;proc rank data=umd out=umd1 group=10;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;by date;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var cum_return;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ranks momr;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;data umd2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set umd1(drop=cum_return);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;momr=momr+1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* MOMR is the portfolio rank variable taking values between 1 and 10:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1 - the lowest momentum group&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;10 - the highest momentum group;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;label momr = "Momentum Portfolio";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/* Assign Ranks to the Next 1 (K) Months After Portfolio Formation*/&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN class="_3oh- _58nk"&gt;&lt;SPAN&gt;******************************************************************************&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN class="_3oh- _58nk"&gt;&lt;SPAN&gt;***&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;* Portfolio return are average monthly returns rebalanced monthly;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create table msfx2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;as select distinct a.momr, a.date as form_date, a.permno,a.Mkcap, b.date, b.ret&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from umd2 as a, msex2 as b&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where a.permno=b.permno&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and 0&amp;lt;intck("month",a.date,b.date)&amp;lt;=&amp;amp;K;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 16:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Problem-Momentum-strategy/m-p/643048#M3830</guid>
      <dc:creator>Lukito</dc:creator>
      <dc:date>2020-04-26T16:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Momentum strategy</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Problem-Momentum-strategy/m-p/643188#M3831</link>
      <description>&lt;P&gt;If the formation window is t-12 through t-2 (an eleven month window), shouldn't your criterion be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where a.permno=b.permno and &amp;amp;K&amp;lt; intck("month", b.date, a.date) &amp;lt;=&amp;amp;J&lt;BR /&gt;...&lt;BR /&gt;having&amp;nbsp;count(b.ret)&amp;nbsp;=&amp;nbsp;%eval(&amp;amp;J-&amp;amp;K)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I take K is the size of the gap (in months) between the end of the formation window and the current date.&amp;nbsp; I.e. with J=12 and K=1, then&amp;nbsp; to form a window in December, use the months of then prior December through current October.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the macro function %eval(&amp;amp;J=&amp;amp;K) to generalize the program.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 03:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Problem-Momentum-strategy/m-p/643188#M3831</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-04-27T03:53:07Z</dc:date>
    </item>
  </channel>
</rss>

