<?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: N day Exponential Moving Average in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864417#M341376</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought it should be simple to use proc expand to get exponential moving average (EMA), however, look like I am missing something here. In the example of calculating EMA in the link below, I can't add the value of lookback day, say 50 day EMA.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't know what this means: "I can't add the value of lookback day, say 50 day EMA". Please explain further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;50 day? EMA? (By the way, there is EWMA, WMA, MA but no EMA). If you mean EWMA, there is no such thing as a 50 day EWMA, the EWMA uses ALL history, weighted exponentially.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Mar 2023 21:16:14 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-03-15T21:16:14Z</dc:date>
    <item>
      <title>N day Exponential Moving Average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864413#M341373</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I thought it should be simple to use proc expand to get exponential moving average (EMA), however, look like I am missing something here. In the example of calculating EMA in the link below, I can't add the value of lookback day, say 50 day EMA.&lt;/P&gt;
&lt;P&gt;Can you please help to get the 50 day EMA?&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2016/01/27/moving-average-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2016/01/27/moving-average-in-sas.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title "Monthly IBM Stock Price";
proc sort data=sashelp.stocks(where=(STOCK='IBM') rename=(Date=t Close=y)) 
          out=Series;
  by t;
run;

proc expand data=Series out=out method=none;
   id t;
   convert y = EWMA / transout=(ewma 0.3);
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;</description>
      <pubDate>Wed, 15 Mar 2023 21:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864413#M341373</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2023-03-15T21:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: N day Exponential Moving Average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864417#M341376</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought it should be simple to use proc expand to get exponential moving average (EMA), however, look like I am missing something here. In the example of calculating EMA in the link below, I can't add the value of lookback day, say 50 day EMA.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't know what this means: "I can't add the value of lookback day, say 50 day EMA". Please explain further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;50 day? EMA? (By the way, there is EWMA, WMA, MA but no EMA). If you mean EWMA, there is no such thing as a 50 day EWMA, the EWMA uses ALL history, weighted exponentially.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 21:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864417#M341376</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-15T21:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: N day Exponential Moving Average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864418#M341377</link>
      <description>&lt;P&gt;Hi PaigeMiller,&lt;/P&gt;
&lt;P&gt;I got the definition of EMA in the link below. Should it be match with the concept of&amp;nbsp;&lt;SPAN&gt;EWMA.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If so, is the parameter 0.3 in the below formula is [2: (N observation+1)] as in the investopedia link?&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class="sas"&gt;convert y = EWMA / transout=&lt;SPAN&gt;(&lt;/SPAN&gt;ewma &lt;SPAN&gt;0.3&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.investopedia.com/terms/e/ema.asp#:~:text=Finally%2C%20the%20following%20formula%20is,)%20x%20(1%2Dmultiplier)" target="_blank"&gt;https://www.investopedia.com/terms/e/ema.asp#:~:text=Finally%2C%20the%20following%20formula%20is,)%20x%20(1%2Dmultiplier)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P class="comp mntl-sc-block finance-sc-block-html mntl-sc-block-html"&gt;Next, you must calculate the multiplier for smoothing (weighting) the EMA, which typically follows the formula: [2 ÷ (number of observations + 1)]. For a 20-day moving average, the multiplier would be [2/(20+1)]= 0.0952.&lt;/P&gt;
&lt;DIV id="mntl-sc-block_1-0-25" class="comp mntl-sc-block mntl-sc-block-adslot mntl-block"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P class="comp mntl-sc-block finance-sc-block-html mntl-sc-block-html"&gt;Finally, the following formula is used to calculate the current EMA:&lt;/P&gt;
&lt;DIV id="mntl-sc-block_1-0-27" class="comp mntl-sc-block mntl-sc-block-adslot mntl-block"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;UL id="mntl-sc-block_1-0-28" class="comp mntl-sc-block finance-sc-block-html mntl-sc-block-html"&gt;
&lt;LI&gt;EMA = Closing price x multiplier + EMA (previous day) x (1-multiplier)&lt;/LI&gt;
&lt;/UL&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 15 Mar 2023 21:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864418#M341377</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2023-03-15T21:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: N day Exponential Moving Average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864444#M341380</link>
      <description>&lt;P&gt;So, the alpha in EWMA formula = 2/(N observation +1)&lt;/P&gt;
&lt;P&gt;if 20 EMA or 20 EWMA, alpha = 2/(20+1)&lt;/P&gt;
&lt;PRE class="sas"&gt;convert y = EWMA / transout=&lt;SPAN&gt;(&lt;/SPAN&gt;ewma &lt;SPAN&gt;ALPHA&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;HHC&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 23:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864444#M341380</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2023-03-15T23:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: N day Exponential Moving Average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864482#M341398</link>
      <description>&lt;P&gt;SAS does not have an EMA (Exponential Moving Average). Whether or not it is the same as the EWMA (Exponentially Weighted Moving Average) in SAS, I leave that to you and others.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 10:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/N-day-Exponential-Moving-Average/m-p/864482#M341398</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-16T10:05:39Z</dc:date>
    </item>
  </channel>
</rss>

