<?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: Calculating Change in a Variable - Momentum Portfolios in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/376941#M276666</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table mom as
select group_tcode as stock, datepart(last_trading_date) as date, price_relative-1 as return, mkt_prel-1 as mkt, volume_total as vol, total_capital as size
from test where price_relative ^= -9 and price_relative ^= -99 and ltd_yr &amp;gt; (&amp;amp;begyear-2) and ltd_yr &amp;lt; (&amp;amp;endyear+1) 
group by last_trading_date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above code creates the MOM table referenced in the previous code. The code is all based on the code referred to in this document:&amp;nbsp; &lt;A href="https://communities.sas.com/kntur85557/attachments/kntur85557/programming/36255/2/Get%20Momentum%20Stocks%20_%20WRDS%20SAS%20Code.pdf" target="_self"&gt;Get Momentum Stocks&lt;/A&gt;&lt;/P&gt;&lt;P&gt;(refer to step 3 to find where I am up to in my code)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each respective stock and 'j' month period, the output is currently the cumulative returns. I wish to also calculate the change in trading volume over the same 'j' month period (once again differing for each stock).&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;</description>
    <pubDate>Tue, 18 Jul 2017 11:28:16 GMT</pubDate>
    <dc:creator>AMOG</dc:creator>
    <dc:date>2017-07-18T11:28:16Z</dc:date>
    <item>
      <title>Calculating Change in a Variable - Momentum Portfolios</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/376903#M276664</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hey Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just after a hand with the below code. In addition to calculating the cumulative return over J months, I need to calculate the change the 'vol' variable over 'j' months. I keep running into problems where it refers to the wrong vol data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance would be great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&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;proc sql;
create table umd as
select distinct a.stock, a.date, a.vol, sum(log(b.return) - log(b.mkt)) as cum_return
from mom as a, mom as b
where a.stock=b.stock and 0&amp;lt;intck('month',b.date,a.date)&amp;lt;(&amp;amp;J)
group by a.stock, a.date;
having count(b.return)=&amp;amp;J;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 09:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/376903#M276664</guid>
      <dc:creator>AMOG</dc:creator>
      <dc:date>2017-07-18T09:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Change in a Variable - Momentum Portfolios</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/376937#M276665</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154553"&gt;@AMOG&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Please provide sample data (data step creating such data) which ideally works with the code you've posted. Then explain what you want to do and show us how your desired output should look like (based on the sample source data).&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 11:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/376937#M276665</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-07-18T11:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Change in a Variable - Momentum Portfolios</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/376941#M276666</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table mom as
select group_tcode as stock, datepart(last_trading_date) as date, price_relative-1 as return, mkt_prel-1 as mkt, volume_total as vol, total_capital as size
from test where price_relative ^= -9 and price_relative ^= -99 and ltd_yr &amp;gt; (&amp;amp;begyear-2) and ltd_yr &amp;lt; (&amp;amp;endyear+1) 
group by last_trading_date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above code creates the MOM table referenced in the previous code. The code is all based on the code referred to in this document:&amp;nbsp; &lt;A href="https://communities.sas.com/kntur85557/attachments/kntur85557/programming/36255/2/Get%20Momentum%20Stocks%20_%20WRDS%20SAS%20Code.pdf" target="_self"&gt;Get Momentum Stocks&lt;/A&gt;&lt;/P&gt;&lt;P&gt;(refer to step 3 to find where I am up to in my code)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each respective stock and 'j' month period, the output is currently the cumulative returns. I wish to also calculate the change in trading volume over the same 'j' month period (once again differing for each stock).&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;</description>
      <pubDate>Tue, 18 Jul 2017 11:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/376941#M276666</guid>
      <dc:creator>AMOG</dc:creator>
      <dc:date>2017-07-18T11:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Change in a Variable - Momentum Portfolios</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/376961#M276667</link>
      <description>&lt;P&gt;The code in your link references existing tables that nobody here has access to, and there's no information about dataset structure of the initial tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please use the macro provided in&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; to convert your dataset "test" into a data step for posting here (limit the number of obs so that your issues are properly illustrated).&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 12:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/376961#M276667</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-18T12:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Change in a Variable - Momentum Portfolios</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/377008#M276668</link>
      <description>&lt;P&gt;Apologies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.TEST;&lt;BR /&gt;&amp;nbsp; infile datalines dsd truncover;&lt;BR /&gt;&amp;nbsp; input last_trading_date:DATETIME. group_tcode:$6. ltd_yr:BEST12. ltd_mo:BEST12. price_relative:BEST12. total_capital:BEST12. volume_total:BEST12. mkt_prel:BEST12.;&lt;BR /&gt;&amp;nbsp; format last_trading_date DATETIME. ltd_yr BEST12. ltd_mo BEST12. price_relative BEST12. total_capital BEST12. volume_total BEST12. mkt_prel BEST12.;&lt;BR /&gt;datalines4;&lt;BR /&gt;31MAY01:00:00:00,rth1,2001,5,1,266537577383,177502,1.01&lt;BR /&gt;31MAY01:00:00:00,mgl1,2001,5,1.01,3175569405,4099662,1.01&lt;BR /&gt;31MAY01:00:00:00,bsc1,2001,5,-9,201231150,0,1.01&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 14:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Change-in-a-Variable-Momentum-Portfolios/m-p/377008#M276668</guid>
      <dc:creator>AMOG</dc:creator>
      <dc:date>2017-07-18T14:03:20Z</dc:date>
    </item>
  </channel>
</rss>

