<?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 How to code A(t-250)*A(t-249)* ... A(t-1) efficently in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490175#M128174</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;I am trying to create a reference price measure that is an average of past 250 days stock prices, weighted by the probabilities of a stock not being traded since the date of the corresponding price:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;reference_price&lt;/SPAN&gt;&lt;SUB&gt;t&lt;/SUB&gt;&lt;SPAN&gt;=(price&lt;/SPAN&gt;&lt;SUB&gt;t-250&lt;/SUB&gt;&lt;SPAN&gt;*turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-250&lt;/SUB&gt;&lt;SPAN&gt;*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-249&lt;/SUB&gt;&lt;SPAN&gt;)*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-248&lt;/SUB&gt;&lt;SPAN&gt;)*...*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-1&lt;/SUB&gt;&lt;SPAN&gt;)+price&lt;/SPAN&gt;&lt;SUB&gt;t-249&lt;/SUB&gt;&lt;SPAN&gt;*turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-249&lt;/SUB&gt;&lt;SPAN&gt;*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-248&lt;/SUB&gt;&lt;SPAN&gt;)*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-247&lt;/SUB&gt;&lt;SPAN&gt;)*...*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-1&lt;/SUB&gt;&lt;SPAN&gt;)+...+price&lt;/SPAN&gt;&lt;SUB&gt;t-1&lt;/SUB&gt;&lt;SPAN&gt;*turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-1&lt;/SUB&gt;&lt;SPAN&gt;)/k, where k is a constant that ensure price weights add up to 1 (see the formula below).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following link is for STATA:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.statalist.org/forums/forum/general-stata-discussion/general/1329146-generating-a-reference-price-measure-as-a-probability-weighted-sum-of-past-stock-prices" target="_blank"&gt;https://www.statalist.org/forums/forum/general-stata-discussion/general/1329146-generating-a-reference-price-measure-as-a-probability-weighted-sum-of-past-stock-prices&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each stock, how to code the reference price in SAS? Price, Turnover ratio each day are given.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks very much!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Aug 2018 17:03:54 GMT</pubDate>
    <dc:creator>ZZB</dc:creator>
    <dc:date>2018-08-27T17:03:54Z</dc:date>
    <item>
      <title>How to code A(t-250)*A(t-249)* ... A(t-1) efficently</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490175#M128174</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;I am trying to create a reference price measure that is an average of past 250 days stock prices, weighted by the probabilities of a stock not being traded since the date of the corresponding price:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;reference_price&lt;/SPAN&gt;&lt;SUB&gt;t&lt;/SUB&gt;&lt;SPAN&gt;=(price&lt;/SPAN&gt;&lt;SUB&gt;t-250&lt;/SUB&gt;&lt;SPAN&gt;*turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-250&lt;/SUB&gt;&lt;SPAN&gt;*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-249&lt;/SUB&gt;&lt;SPAN&gt;)*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-248&lt;/SUB&gt;&lt;SPAN&gt;)*...*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-1&lt;/SUB&gt;&lt;SPAN&gt;)+price&lt;/SPAN&gt;&lt;SUB&gt;t-249&lt;/SUB&gt;&lt;SPAN&gt;*turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-249&lt;/SUB&gt;&lt;SPAN&gt;*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-248&lt;/SUB&gt;&lt;SPAN&gt;)*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-247&lt;/SUB&gt;&lt;SPAN&gt;)*...*(1-turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-1&lt;/SUB&gt;&lt;SPAN&gt;)+...+price&lt;/SPAN&gt;&lt;SUB&gt;t-1&lt;/SUB&gt;&lt;SPAN&gt;*turnover_ratio&lt;/SPAN&gt;&lt;SUB&gt;t-1&lt;/SUB&gt;&lt;SPAN&gt;)/k, where k is a constant that ensure price weights add up to 1 (see the formula below).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following link is for STATA:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.statalist.org/forums/forum/general-stata-discussion/general/1329146-generating-a-reference-price-measure-as-a-probability-weighted-sum-of-past-stock-prices" target="_blank"&gt;https://www.statalist.org/forums/forum/general-stata-discussion/general/1329146-generating-a-reference-price-measure-as-a-probability-weighted-sum-of-past-stock-prices&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each stock, how to code the reference price in SAS? Price, Turnover ratio each day are given.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks very much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 17:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490175#M128174</guid>
      <dc:creator>ZZB</dc:creator>
      <dc:date>2018-08-27T17:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to code A(t-250)*A(t-249)* ... A(t-1) efficently</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490178#M128177</link>
      <description>&lt;P&gt;The format of the dataset is as follow:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Price&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Turnover&lt;/P&gt;
&lt;P&gt;AAA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1990/08/25&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.05&lt;/P&gt;
&lt;P&gt;AAA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1990/08/26&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8.05&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.06&lt;/P&gt;
&lt;P&gt;.....&lt;/P&gt;
&lt;P&gt;BBB&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CCC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and so on&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 17:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490178#M128177</guid>
      <dc:creator>ZZB</dc:creator>
      <dc:date>2018-08-27T17:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to code A(t-250)*A(t-249)* ... A(t-1) efficently</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490196#M128182</link>
      <description>&lt;P&gt;Do you have SAS/ETS?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Aug 2018 17:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490196#M128182</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-08-27T17:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to code A(t-250)*A(t-249)* ... A(t-1) efficently</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490293#M128234</link>
      <description>I am not sure if my sas has it. How to check it?&lt;BR /&gt;&lt;BR /&gt;If I have it, how to code it?&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Aug 2018 01:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490293#M128234</guid>
      <dc:creator>ZZB</dc:creator>
      <dc:date>2018-08-28T01:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to code A(t-250)*A(t-249)* ... A(t-1) efficently</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490562#M128367</link>
      <description>&lt;P&gt;Any help? Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 17:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490562#M128367</guid>
      <dc:creator>ZZB</dc:creator>
      <dc:date>2018-08-28T17:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to code A(t-250)*A(t-249)* ... A(t-1) efficently</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490568#M128371</link>
      <description>&lt;P&gt;I use the simple data steps to calculate the above formula, in this case I just replace "t-250" with "t-4" for simplicity.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I want to back to t-250, how to code efficiently?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/****************************************/&lt;/P&gt;
&lt;P&gt;*proc printto log=junk;&lt;BR /&gt;proc expand data=MSF out=TO method=none;&lt;BR /&gt;by permno;&lt;BR /&gt;id date;&lt;BR /&gt;convert TO = Lead_TO / transformout=(lead 1);&lt;BR /&gt;run;&lt;BR /&gt;*proc printto;&lt;/P&gt;
&lt;P&gt;data TO1;&lt;BR /&gt;set TO;&lt;BR /&gt;Lead_TO_1=1-Lead_TO;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;*proc printto log=junk;&lt;BR /&gt;proc expand data=TO1 (keep=permno date prc TO Lead_TO_1) out=TO2 method=none;&lt;BR /&gt;by permno;&lt;BR /&gt;id date;&lt;BR /&gt;convert Lead_TO_1 = CUM_Lead_TO3 / transformout=(MOVPROD 3 trimleft 2); *** 1990/5 vs. 1990/1, 3=Date interval - 1;&lt;BR /&gt;convert Lead_TO_1 = CUM_Lead_TO2 / transformout=(MOVPROD 2 trimleft 1); *** 1990/5 vs. 1990/2;&lt;BR /&gt;convert Lead_TO_1 = CUM_Lead_TO1 / transformout=(MOVPROD 1); *** 1990/5 vs. 1990/3;&lt;BR /&gt;run;&lt;BR /&gt;*proc printto;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;*proc printto log=junk;&lt;BR /&gt;proc expand data=TO2 out=TO3 method=none;&lt;BR /&gt;by permno;&lt;BR /&gt;id date;&lt;BR /&gt;convert CUM_Lead_TO3 = Lead_CUM_Lead_TO3 / transformout=(lead 2); *** 1990/5 vs. 1990/1;&lt;BR /&gt;convert CUM_Lead_TO2 = Lead_CUM_Lead_TO2 / transformout=(lead 1); *** 1990/5 vs. 1990/2;&lt;BR /&gt;run;&lt;BR /&gt;*proc printto;&lt;/P&gt;
&lt;P&gt;data TO4;&lt;BR /&gt;set TO3;&lt;BR /&gt;PRC4=PRC*TO*Lead_CUM_Lead_TO3;&lt;BR /&gt;PRC3=PRC*TO*Lead_CUM_Lead_TO2;&lt;BR /&gt;PRC2=PRC*TO*Lead_TO_1;&lt;BR /&gt;PRC1=PRC*TO;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data TO4;&lt;BR /&gt;set TO4;&lt;BR /&gt;K4=TO*Lead_CUM_Lead_TO3;&lt;BR /&gt;K3=TO*Lead_CUM_Lead_TO2;&lt;BR /&gt;K2=TO*Lead_TO_1;&lt;BR /&gt;K1=TO;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;*proc printto log=junk;&lt;BR /&gt;proc expand data=TO4 out=TO5 method=none;&lt;BR /&gt;by permno;&lt;BR /&gt;id date;&lt;BR /&gt;convert PRC4 = LAG_TO4 / transformout=(lag 4);&lt;BR /&gt;convert PRC3 = LAG_TO3 / transformout=(lag 3);&lt;BR /&gt;convert PRC2 = LAG_TO2 / transformout=(lag 2);&lt;BR /&gt;convert PRC1 = LAG_TO1 / transformout=(lag 1);&lt;/P&gt;
&lt;P&gt;convert K4 = LAG_K4 / transformout=(lag 4);&lt;BR /&gt;convert K3 = LAG_K3 / transformout=(lag 3);&lt;BR /&gt;convert K2 = LAG_K2 / transformout=(lag 2);&lt;BR /&gt;convert K1 = LAG_K1 / transformout=(lag 1);&lt;BR /&gt;run;&lt;BR /&gt;*proc printto;&lt;/P&gt;
&lt;P&gt;data TO6;&lt;BR /&gt;set TO5;&lt;BR /&gt;RP=(LAG_TO4+LAG_TO3+LAG_TO2+LAG_TO1)/(LAG_K4+LAG_K3+LAG_K2+LAG_K1);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 18:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490568#M128371</guid>
      <dc:creator>ZZB</dc:creator>
      <dc:date>2018-08-28T18:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to code A(t-250)*A(t-249)* ... A(t-1) efficently</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490669#M128435</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13438"&gt;@ZZB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I am not sure if my sas has it. How to check it?&lt;BR /&gt;&lt;BR /&gt;If I have it, how to code it?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think that you may actually want IML, SAS's matrix language more than ETS. ETS does time series analysis but I haven't had a license for 20 years so no practice...&lt;/P&gt;
&lt;P&gt;To check license run:&lt;/P&gt;
&lt;PRE&gt;Proc setinit;
run;
&lt;/PRE&gt;
&lt;P&gt;If you see SAS/ETS in the output of the log you have a license for ETS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have the license run:&lt;/P&gt;
&lt;PRE&gt;Proc product_status;
run;&lt;/PRE&gt;
&lt;P&gt;to see if it is installed. If licensed and not installed then update the installation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 23:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-code-A-t-250-A-t-249-A-t-1-efficently/m-p/490669#M128435</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-28T23:18:30Z</dc:date>
    </item>
  </channel>
</rss>

