<?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 Rolling std in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Rolling-std/m-p/182196#M46425</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: &lt;/P&gt;&lt;P&gt;Sorry for not responding earlier.&lt;/P&gt;&lt;P&gt;This is the problem I mentioned in my earlier post &lt;A __default_attr="225409" __jive_macro_name="message" class="jive_macro jive_macro_message active_link" href="https://communities.sas.com/" modifiedtitle="true" style="color: #2989c5;" title="Re: rolling standard deviation calculation"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The time period in the sample dataset started from 1990. So, when we compute std using 24-month interval, the std observation corresponding to 1991 should be missing since we do not have 24 returns till 1991. The code returns a std for 1991 too using whatever returns are available. With proc sql, I use TRIMLEFT=23 to take care of that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had created the month variable in earlier dataset using the date variable.&lt;/P&gt;&lt;P&gt;Anyway, a sample of the original dataset is attached. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Sep 2014 19:27:00 GMT</pubDate>
    <dc:creator>namrata</dc:creator>
    <dc:date>2014-09-01T19:27:00Z</dc:date>
    <item>
      <title>Rolling std</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rolling-std/m-p/182196#M46425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: &lt;/P&gt;&lt;P&gt;Sorry for not responding earlier.&lt;/P&gt;&lt;P&gt;This is the problem I mentioned in my earlier post &lt;A __default_attr="225409" __jive_macro_name="message" class="jive_macro jive_macro_message active_link" href="https://communities.sas.com/" modifiedtitle="true" style="color: #2989c5;" title="Re: rolling standard deviation calculation"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The time period in the sample dataset started from 1990. So, when we compute std using 24-month interval, the std observation corresponding to 1991 should be missing since we do not have 24 returns till 1991. The code returns a std for 1991 too using whatever returns are available. With proc sql, I use TRIMLEFT=23 to take care of that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had created the month variable in earlier dataset using the date variable.&lt;/P&gt;&lt;P&gt;Anyway, a sample of the original dataset is attached. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Sep 2014 19:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rolling-std/m-p/182196#M46425</guid>
      <dc:creator>namrata</dc:creator>
      <dc:date>2014-09-01T19:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling std</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rolling-std/m-p/182197#M46426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK. I understood what you mean. You want all of these 24 month have data when you compute STD ?&lt;/P&gt;&lt;P&gt;Code is trivial changed on my original code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;proc import datafile='c:\temp\sample.csv' out=temp dbms=csv replace;
guessingrows=32767;
run;
data have;
set temp;
d=mdy(month,1,year);
r=input(ret,?? best32.);
drop date ret;
format d date9.;
run;
 
 
 
 
proc sql ;
create table std as
select *, (select std(r) from have where d between intnx('month',a.d,-36,'s') and intnx('month',a.d,-12,'s') and cusip=a.cusip having intck('month',min(d),max(d))=24) as rolling_std
from have as a;
quit;
 &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 13:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rolling-std/m-p/182197#M46426</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-09-02T13:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling std</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rolling-std/m-p/182198#M46427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you looked into Proc Expand?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 13:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rolling-std/m-p/182198#M46427</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-09-02T13:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling std</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rolling-std/m-p/182199#M46428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Ksharp! I will run the codes on my data and get back to you &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reeza: Yes, I have.&lt;/P&gt;&lt;P&gt;Proc Expand works but in that case, you need to create an additional lag variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 23:17:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rolling-std/m-p/182199#M46428</guid>
      <dc:creator>namrata</dc:creator>
      <dc:date>2014-09-02T23:17:53Z</dc:date>
    </item>
  </channel>
</rss>

