<?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 Calculating rolling standard deviation over the past 12 months in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-rolling-standard-deviation-over-the-past-12-months/m-p/585156#M166820</link>
    <description>&lt;P&gt;How can I calculate the &lt;SPAN&gt;standard deviation of returns over the past 12 months? I have a dataset of daily observations. I have a yearmonth&amp;nbsp;variable. I can use PROC EXPAND and get a rolling standard deviation over the past 252 days using the following code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC EXPAND DATA=daily_returns OUT=daily_returns2;

CONVERT return=std / TRANSFORMOUT=(MOVSTD 252);

by stock;

RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;This would work for most cases, but what if a stock halts trading for several months, this would include returns of days that are more than 1 year ago. I want to use only observations that are strictly within the past 12 months.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Another related issue is that, say a stock stops trading for more than a year, and then reappear. These days without trading would still appear in my dataset with missing values for returns. However, my code still returns the rolling standard deviation values for these observations when it should not. How can I solve this?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Aug 2019 10:39:49 GMT</pubDate>
    <dc:creator>somebody</dc:creator>
    <dc:date>2019-08-30T10:39:49Z</dc:date>
    <item>
      <title>Calculating rolling standard deviation over the past 12 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-rolling-standard-deviation-over-the-past-12-months/m-p/585156#M166820</link>
      <description>&lt;P&gt;How can I calculate the &lt;SPAN&gt;standard deviation of returns over the past 12 months? I have a dataset of daily observations. I have a yearmonth&amp;nbsp;variable. I can use PROC EXPAND and get a rolling standard deviation over the past 252 days using the following code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC EXPAND DATA=daily_returns OUT=daily_returns2;

CONVERT return=std / TRANSFORMOUT=(MOVSTD 252);

by stock;

RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;This would work for most cases, but what if a stock halts trading for several months, this would include returns of days that are more than 1 year ago. I want to use only observations that are strictly within the past 12 months.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Another related issue is that, say a stock stops trading for more than a year, and then reappear. These days without trading would still appear in my dataset with missing values for returns. However, my code still returns the rolling standard deviation values for these observations when it should not. How can I solve this?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 10:39:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-rolling-standard-deviation-over-the-past-12-months/m-p/585156#M166820</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2019-08-30T10:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating rolling standard deviation over the past 12 months</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-rolling-standard-deviation-over-the-past-12-months/m-p/585224#M166857</link>
      <description>Create a table that fills in any missing dates for each stock ahead of time.</description>
      <pubDate>Fri, 30 Aug 2019 14:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-rolling-standard-deviation-over-the-past-12-months/m-p/585224#M166857</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-08-30T14:38:12Z</dc:date>
    </item>
  </channel>
</rss>

