<?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: Create rolling 12 month window for daily data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312919#M61450</link>
    <description>&lt;P&gt;OK, here is a program that deconstructs the task, losing efficiency (for instance it does not combine generation of monthly SSCP with accumulating 12-month rolling SSCP:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The program is untested, so I recommend you test it on&amp;nbsp;2 permnos with 13 months each (i.e. use something like&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; where permno in (12404,16801) and date between ('01jan2011'd and 31jan2012'd&lt;BR /&gt;in the first data step.&lt;BR /&gt;&lt;BR /&gt;That's 4 rolling 12-month windows (JAN-DEC and FEB-JAN for each permno).&amp;nbsp; Then you can test the regression using this program&amp;nbsp;against a direct PROC REG.&amp;nbsp; Just run the direct proc reg's as follows:&lt;BR /&gt;&amp;nbsp; proc reg data=have;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where permno=12404 and date between '01jan2011'd and '31dec2012'd;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; model ...&lt;BR /&gt;&amp;nbsp; quit;&lt;BR /&gt;&amp;nbsp; proc reg data=have;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where permno=12404 and date between '01feb2011'd and '31jan2012'd;&lt;BR /&gt;&lt;BR /&gt;Do same for permno 16801&lt;BR /&gt;&lt;BR /&gt;I suggest you not only compare the proc reg results, but take a look to the intermediate datasets to see the work that is taking place.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;When you run the real data, do NOT run the PROC REG at the end as I have specified it.&amp;nbsp;&amp;nbsp; You'll need at least to put in a NOPRINT statement and also some keywords to output the r-square, total residuals, and estimated coefficients.&amp;nbsp;&amp;nbsp; I have it there just as a placeholder.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Notice you have to specific&amp;nbsp;two macrovars:
&lt;OL&gt;
&lt;LI&gt;varnames&amp;nbsp;&amp;nbsp; .. a list of variables that MIGHT be in the model.&amp;nbsp; You can list, say 10 variables,&amp;nbsp; and later on when you run PROC REGs, you can specific a subset in your model statement.&amp;nbsp; I've just put in&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %let varnames= RET FACTOR1 FACTOR2 FACTOR3&lt;BR /&gt; as an example&lt;/LI&gt;
&lt;LI&gt;NM .. number of months in your rolling windows.&amp;nbsp; I put in %let NM=12;&lt;BR /&gt;&lt;BR /&gt;A third macro variable NRC is created by the program.&amp;nbsp; NRC is the number of rows (and number of&amp;nbsp;columns) in the generated SSCP matrix.&amp;nbsp; It equals the number of vars in VARNAMES plus 1&amp;nbsp; (for the intercept term).&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;The sequence of steps are these:
&lt;OL&gt;
&lt;LI&gt;data vtemp / view=vtemp&lt;BR /&gt;Make a data set with a fixed value MONTH_END_DATE for every record.&amp;nbsp; This is needed by the BY STATEMENT in the next proc.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;PROC REG.&amp;nbsp;&amp;nbsp; Notice that this reg procedure does NOT estimate models.&amp;nbsp; All is does is generate an SSCP for each permno/month_end_date.&amp;nbsp;&amp;nbsp; These are the value that need to be aggregated into 12-month rolling windows.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;DATA SSCP_FINAL&amp;nbsp;This one aggregate the rolling windows and puts them into a data set file (SSCP_FINAL), for submission to any regression you want to run.&amp;nbsp; SSCP_FINAL has the "TYPE=SSCP" data set name parameter.&amp;nbsp; Setting this attribute for the data set is neccessary for subsequent proc reg's to recognize that these are not regular data files.&amp;nbsp; Also note it has the "if month_n&amp;gt;=&amp;amp;nm then output;"&amp;nbsp; This prevent outputting windows before the first 12-months have been read in.&lt;BR /&gt;&lt;BR /&gt;IMPORTANT, IMPORTANT:&amp;nbsp; This program assumes there are no "holes" in any window.&amp;nbsp; I.e. a given permno has at least one active trading date in every month from its first month to its last month.&amp;nbsp; This is probably a safe assumption in most cases, but remember: a stock can be termporarily delisted from an exchange, often when its price goes below a certain value.&amp;nbsp; If it regains value it can be relisted.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;PROC REG.&amp;nbsp; This is where you run you model or models.&amp;nbsp; Note this can be done later, because once you have generated SSCP_FINAL, you have the 12-month rolling SSCP values for all the estimations you need.&amp;nbsp; Just remember that all the PROC REGs you run against SSCP_FINAL have to have a "by permno month_end_date;" statement.&lt;BR /&gt;&lt;BR /&gt;And as mentioned earlier, you probably want to put a NOPRINT option on this proc reg, and then use various parameters on it to store you R-squared, total residuals, and estimated coefficents in a separated data set.&lt;/LI&gt;
&lt;LI&gt;Again,&amp;nbsp;the efficieny loss here is that the data are passed through 2 times to get SSCP_FINAL.&amp;nbsp; Both tasks&amp;nbsp;could be done in a single DATA step, but the program simplification here might be worth it.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;editted addition.&amp;nbsp; Notice that in the SSCP_FINAL step I use lag&amp;amp;nrc&amp;nbsp; (which is LAG5 in this case).&amp;nbsp; That is I am using a 5-deep lag queue.&amp;nbsp; The reason is the every "record"&amp;nbsp;&amp;nbsp;in the incoming SSCP is a single row in the 5*5 matrix.&amp;nbsp; One row for _NAME_="intercept", one for _NAME_="ret", one for _name_="FACTOR1"&amp;nbsp; through "FACTOR3".&amp;nbsp; This means that the each month has 5 records, so to get lagged values for corresponding records, I use LAG5, not LAG.&amp;nbsp; Of course, if the user specifies, say 8 variables in macrovar VARNAMES, then there are 9 rows per month.&amp;nbsp; That's why this program uses LAG&amp;amp;nrc - it automatically adjusts for the size of the SSCP matrix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MK&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;/* Names of variables that might be part of models*/
%let varnames=ret factor1 factor2 factor3; 

%let NM=12;  /* Number of months per rolling window */

/* Get size of SSCP matrix (one row/col per variable &amp;amp; 1 row/col for intercept)*/
%let nrc=%eval(1+  %sysfunc(countw(&amp;amp;varnames,%str( ))));


/* Make a dataset view with fixed value (month_end_date) for each month*/
data vtemp / view=vtemp;
  set have;
  month_end_date=intnx('month',date,0,'end');
  format month_end_date yymmddn8.;
run;

/* Use proc reg to make SSCP for each month */
/* Notice there is no MODEL statement       */
proc reg data=vtemp noprint outsscp=sscp (where=(_type_='SSCP')) ;
  var &amp;amp;varnames;
  by permno month_end_date;
run;

/* Now accumlate rolling total 12-month SSCP values */
data sscp_final (type=sscp drop=row col month_n);

  array total_sscp{&amp;amp;nrc,&amp;amp;nrc} _temporary_ ;

  do row=1 to &amp;amp;nrc; do col=1 to &amp;amp;nrc; total_sscp{row,col}=0; end; end;

  do month_n=1 by 1 until (last.permno);
    do row=1 to &amp;amp;nrc;
      set sscp;
      by permno;
      array vars  {*} intercept &amp;amp;varnames;
	  do col=1 to &amp;amp;nrc;
        total_sscp{row,col}=total_sscp{row,col}+vars{col}-ifn(month_n&amp;gt;&amp;amp;nm,lag&amp;amp;nrc(vars{col}),0);
      end;
	  do col=1 to &amp;amp;nrc;
	    vars{col}=total_sscp{row,col};
	  end;
	  if month_n&amp;gt;=&amp;amp;nm then output;
    end;
  end;
run;

/* And run the regression for each permno/month_end_date */
proc reg data=sscp_final ;
  by permno month_end_date;
  var &amp;amp;varnames;
  model ret=factor1 factor2 factor3 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 20 Nov 2016 18:53:11 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2016-11-20T18:53:11Z</dc:date>
    <item>
      <title>Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312194#M61387</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the code to create rolling window for 12 months (t-12) to calculate R2, residual... for month t .&lt;/P&gt;&lt;P&gt;For ex,&amp;nbsp;&lt;/P&gt;&lt;P&gt;01JAN2000 to 31DEC2000 --&amp;gt; &amp;nbsp;JAN2001&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;01FEB2000 to 31JAN2001 ---&amp;gt; &amp;nbsp;FEB 2001&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;01MAR2000 to 31FEB2001 &amp;nbsp;---&amp;gt; MAR 2001 &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I can run with monthly data, but for DAILYdata I cannot use this code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;BR /&gt;create table Form100&lt;BR /&gt;as select distinct a.permno, a.date as end, b.ret, b.date&lt;BR /&gt;from crsp3 (keep=permno date) as a, crsp3 as b&lt;BR /&gt;where a.permno=b.permno and 1&amp;lt;=intck("month", b.date, a.date)&amp;lt;&amp;amp;J and 0&amp;lt;=intck("year",b.date,a.date)&amp;lt;=1&lt;BR /&gt;group by a.permno, a.date;&lt;BR /&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could you please me with this? THank you very much.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;HA&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 04:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312194#M61387</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2016-11-17T04:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312201#M61388</link>
      <description>&lt;P&gt;Do you mean:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;where a.permno=b.permno and &amp;nbsp; &amp;nbsp;/* &amp;nbsp;1&amp;lt;=intck("month", b.date, a.date)&amp;lt;&amp;amp;J and 0&amp;lt;=intck("year",b.date,a.date)&amp;lt;=1 */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;b.date &amp;lt;= intnx('year',a.date,1,same)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what do you have in&lt;STRONG&gt; &amp;amp;j&lt;/STRONG&gt; ? - did you assigned it a value ?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 04:49:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312201#M61388</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-17T04:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312207#M61389</link>
      <description>&lt;P&gt;Yes, I did assign it J=12&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 05:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312207#M61389</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2016-11-17T05:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312210#M61390</link>
      <description>have you tried change the where clause as offered ?</description>
      <pubDate>Thu, 17 Nov 2016 05:21:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312210#M61390</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-17T05:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312214#M61391</link>
      <description>&lt;P&gt;Thank you so much, I did try, but a.date just shifts one day,&amp;nbsp;and I need it shift for one month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 05:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312214#M61391</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2016-11-17T05:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312216#M61392</link>
      <description>&lt;P&gt;sorry it is not clear enough to me.&lt;/P&gt;
&lt;P&gt;give an example by values of&amp;nbsp;&lt;SPAN&gt;a.date= ... &amp;nbsp; &amp;nbsp; b.date= .... &amp;nbsp; &amp;nbsp;&lt;U&gt;valid period&lt;/U&gt; from date= &amp;nbsp; &amp;nbsp;to date= &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 05:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312216#M61392</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-11-17T05:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312218#M61393</link>
      <description>&lt;P&gt;I mean&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b. date from 01JAN2000 to 31DEC2000 --&amp;gt; &amp;nbsp;it will be used for hold year to calculate in JAN2001 (a.date, can be 01Jan2001 or 31 jan2001, it is not important)&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;b. date from 01FEB2000 to 31JAN2001 ---&amp;gt; &amp;nbsp;will be used for next month in FEB 2001 (a.date shift one month)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;b. date from 01MAR2000 to 31FEB2001 &amp;nbsp;---&amp;gt; MAR 2001 &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 05:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312218#M61393</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2016-11-17T05:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312229#M61394</link>
      <description>&lt;P&gt;You could also consider creating a table with the start/end dates that feed your intervals and then use that in your query when joining.&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 06:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312229#M61394</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-17T06:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312237#M61395</link>
      <description>&lt;P&gt;Thank you, I am a beginner of Sas so I am trying to find how to create table as you said. But I am running daily stock return for US market, could it use for very large data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 07:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312237#M61395</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2016-11-17T07:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312258#M61396</link>
      <description>&lt;P&gt;How large is your data? Do you need to add in all the data for the 12 months or are you trying to calculate some sort of statistics across the interval. Otherwise you're going to be multiplying the size of your data significantly since each record will belong to multiple intervals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, do you have SAS/ETS? Have you looked at PROC TIMESERIES or EXPAND?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 09:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312258#M61396</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-17T09:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312263#M61397</link>
      <description>&lt;P&gt;it is good for SQL to get ROLLING window.&lt;/P&gt;
&lt;P&gt;code not tested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table Form100
as
 select a.permno, a.date as end, 

(select sum(residual) from crsp3 where permno=a.permno 
 and date between a.date and intnx('year',a.date,1,'s')-1 )
as sum_residual

from crsp3 (keep=permno date) as a

group by a.permno, a.date;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Nov 2016 10:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312263#M61397</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-11-17T10:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312322#M61398</link>
      <description>&lt;P&gt;Thank you, I am going to check now. But I want create rolling window to calculate R2, residual (must use proc preg for regression market model) and skewness.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So can i combine proc preg and proc sql? and how about skewness?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much,&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 13:17:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312322#M61398</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2016-11-17T13:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312327#M61399</link>
      <description>&lt;P&gt;My data has 27.612.898 observations. I want to create to run proc preg for R2 and residual (CAPM model) &amp;nbsp;and skewness (has formula). If data is too large, I just use it for calculate one by one, if I can find solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you &amp;nbsp;so much for suggestion, I am just gg search and reading how to use but I have no idea until now.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 13:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312327#M61399</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2016-11-17T13:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312500#M61411</link>
      <description>&lt;P&gt;How many stocks, for how many windows, do you intend to process? The CRSP (Center for Research in Stock Prices) that you are using has daily data on thousands of stocks going back to 1929, so your potential universe is big.&lt;BR /&gt;&lt;BR /&gt;SQL is NOT the solution to such a problem. It's going to compare EVERY record in "crsp as b" to each record in "crsp as a" to determine which records to put in the window. In other words, SQL will ignore the data order (PERMNO/DATE) in most CRSP data sets. Even if SAS marks the dataset as sorted, I suspect SQL won't take advantage (but that could be tested).&lt;BR /&gt;&lt;BR /&gt;And consider the sheer size of the data you want. I suppose you want a new window every month, so that's 12 windows per year. With about 200 trading days per 12 months in each window, you are asking for each stock about 2400 records for a year of data. So multiply N(stocks)*N(years)*2400*(record size) to determine your disk space requirements.&lt;BR /&gt;&lt;BR /&gt;But wait -- there's more! You apparently plan to do a regression on each of the windows, meaning you intend to recalculate sums of squares for 12 month windows, even though you could inherit 11 of those monthly sum-of-squares from the prior window.&lt;BR /&gt;&lt;BR /&gt;Unless you have an unusually small portfolio and date range, try to avoid making a data set of the base data for every windows. &lt;BR /&gt;&lt;BR /&gt;Now that I've sounded the alarm, it is possible that you might get away with making a data set VIEW as opposed to a data set FILE. You could then submit that view to a PROC REG, with a BY WINDOWID statement. It would still be calculating sums-of-squares 12 times as much as needed, but you'd reduce disk space requirements.&lt;BR /&gt;&lt;BR /&gt;Regards, &lt;BR /&gt;Mark&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 02:27:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312500#M61411</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-11-18T02:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312504#M61412</link>
      <description>&lt;P&gt;These two papers I presented at NESUG discuss (1) how to make rolling windows of the original data, and (2) how to make rolling SSCP matrices ready for use in PROC REG.&amp;nbsp; Did you know that there is a sas data set TYPE=SSCP that proc reg accepts?&amp;nbsp; Take a look at these:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;A href="http://www.lexjansen.com/nesug/nesug12/fi/fi08.pdf" target="_blank"&gt;Rolling Regressions with PROC FCMP and PROC REG&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.lexjansen.com/nesug/nesug13/117_Final_Paper.pdf" target="_blank"&gt;Arrays Plus Data Step Plus Cramer's Rule = Fast Rolling Regressions&lt;/A&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd probably avoid making your own implementation of Cramer's rule (I wrote that mostly as an exercise), but even so, the second paper probably provides a better guide to making the rolling TYPE=SSCP data set for to PROC REG.&amp;nbsp;&amp;nbsp;Now remember, submitting an SSCP matrix means you can directly produce TOTAL residuals for each window, but not day-by-day residuals.&amp;nbsp;&amp;nbsp; To do that, you'd have to take the intercept and coefficients estimates for each window and run them against your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 03:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312504#M61412</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-11-18T03:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312505#M61413</link>
      <description>&lt;P&gt;Thank you very much for your suggestion. So I think I will try to another code to solve this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 03:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312505#M61413</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2016-11-18T03:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312507#M61415</link>
      <description>&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciate your support, I am going to find out my code based on your papers now. Hope I can do it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a good day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ha&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 03:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312507#M61415</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2016-11-18T03:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312509#M61416</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/106891"&gt;@yotsuba88﻿&lt;/a&gt;:&amp;nbsp; what other code do you imagine would solve this problem?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 03:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312509#M61416</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-11-18T03:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312510#M61417</link>
      <description>I dont know, I read your alarm message first then your 2 papers. So it is misunderstood, I am reading your papers and trying to apply them.&lt;BR /&gt;&lt;BR /&gt;Best,</description>
      <pubDate>Fri, 18 Nov 2016 03:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312510#M61417</guid>
      <dc:creator>yotsuba88</dc:creator>
      <dc:date>2016-11-18T03:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create rolling 12 month window for daily data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312533#M61422</link>
      <description>&lt;PRE&gt;
Oh. You need use IML or make a macro to call PROC REG.
Some skeleton code like.


data date;
 set have(keep=date);
end_date=intnx('month',date,12,'e');
run;

data _null_;
 set date;
call execute('proc reg data=have(where=(date between '|| date ||' and '||end_date ||' ))  outest=xxx'|| strip(_n_)||'  ;');
..............
run;

data want;
 set xxx:;
run;
&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Nov 2016 07:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Create-rolling-12-month-window-for-daily-data/m-p/312533#M61422</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-11-18T07:22:34Z</dc:date>
    </item>
  </channel>
</rss>

