<?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: rolling regression with macro in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/rolling-regression-with-macro/m-p/173669#M44712</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It appears you are missing the %rollingreg statement to execute the macro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Apr 2014 14:07:44 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2014-04-09T14:07:44Z</dc:date>
    <item>
      <title>rolling regression with macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rolling-regression-with-macro/m-p/173668#M44711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am desperately trying to run a rolling regression of a time series of a hedge fund return on a set of 6 equity and bond factors.I've just tried doing a macro, but still without success.Is there someone who can help me out? I attach the code I've written and the error log information.&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; mylib1.proj;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;set&lt;/SPAN&gt; mylib1.myseries(&lt;SPAN style="color: #0433ff;"&gt;keep&lt;/SPAN&gt;= date Optimus MSCINordicLV MSCINordicSV SandPSwedenSG CreditSuisseHY EcapEuroCorp lag1Optimus);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;run&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/SPAN&gt; rollingreg&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;(data=mylib1.proj ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;out_ds=mylib1.proj1 ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;model_equation= Optimus= MSCINordicLV MSCINordicSV SandPSwedenSG CreditSuisseHY EcapEuroCorp lag1Optimus / noint,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;id= , date=date ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;start_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;/&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/SPAN&gt;/&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/SPAN&gt; ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;end_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt;/&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;11&lt;/STRONG&gt;&lt;/SPAN&gt;/&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;13&lt;/STRONG&gt;&lt;/SPAN&gt; ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;freq=month, s=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;, n=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;/SPAN&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;regprint=noprint);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* Start with empty output data sets;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;proc datasets nolist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;delete _all_ds _outest_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;* Prepare input data for by-id-date use;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;proc sort data=&amp;amp;data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;by &amp;amp;id &amp;amp;date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* Set the 'by-id' variable;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; by_id= ; &lt;/SPAN&gt;*blank default, no by variable;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%length&lt;/SPAN&gt;(&amp;amp;id) &amp;gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; by_id= by &amp;amp;id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* Determine date range variables;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; %&lt;STRONG&gt;&lt;EM&gt;lowcase&lt;/EM&gt;&lt;/STRONG&gt;(&lt;SPAN style="color: #0433ff;"&gt;%substr&lt;/SPAN&gt;(&amp;amp;date,&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;,&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt;))= year &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; year_date=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; year_date=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate1 = &amp;amp;start_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate2 = &amp;amp;end_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* Make start and end date if missing;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;start_date = &lt;SPAN style="color: #0433ff;"&gt;%str&lt;/SPAN&gt;() | &amp;amp;end_date = &lt;SPAN style="color: #0433ff;"&gt;%str&lt;/SPAN&gt;() &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%do&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;proc sql noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;create table _dx1 as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;select min(&amp;amp;date) as min_date, max(&amp;amp;date) as max_date&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;from &amp;amp;data where not missing(&amp;amp;date);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;select min_date into : min_date from _dx1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;select max_date into : max_date from _dx1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* SDATE1 and SDATE2 put in sas date number form (1/1/1960=0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;sdate1 = &lt;SPAN style="color: #0433ff;"&gt;%str&lt;/SPAN&gt;() &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%do&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate1= &amp;amp;min_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%else&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;%do&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; (&lt;SPAN style="color: #0433ff;"&gt;%index&lt;/SPAN&gt;(&amp;amp;sdate1,&lt;SPAN style="color: #0433ff;"&gt;%str&lt;/SPAN&gt;(-)) &amp;gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;) | (&lt;SPAN style="color: #0433ff;"&gt;%index&lt;/SPAN&gt;(&amp;amp;sdate1,&lt;SPAN style="color: #0433ff;"&gt;%str&lt;/SPAN&gt;(/)) &amp;gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate1= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(inputn(&amp;amp;sdate1,mmddyy10.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; ( &lt;SPAN style="color: #0433ff;"&gt;%length&lt;/SPAN&gt;(&amp;amp;sdate1)=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/SPAN&gt; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate1= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(inputn(01&amp;amp;sdate1,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; ( &lt;SPAN style="color: #0433ff;"&gt;%length&lt;/SPAN&gt;(&amp;amp;sdate1)=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt; | &lt;SPAN style="color: #0433ff;"&gt;%length&lt;/SPAN&gt;(&amp;amp;sdate1)=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;9&lt;/STRONG&gt;&lt;/SPAN&gt; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate1= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(inputn(&amp;amp;sdate1,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; ( &lt;SPAN style="color: #0433ff;"&gt;%length&lt;/SPAN&gt;(&amp;amp;sdate1)=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate1= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(inputn(01JAN&amp;amp;sdate1,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate1=&lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(year(&amp;amp;sdate1));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;sdate2 = &lt;SPAN style="color: #0433ff;"&gt;%str&lt;/SPAN&gt;() &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%do&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate2= &amp;amp;max_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%else&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;%do&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; (&lt;SPAN style="color: #0433ff;"&gt;%index&lt;/SPAN&gt;(&amp;amp;sdate2,&lt;SPAN style="color: #0433ff;"&gt;%str&lt;/SPAN&gt;(-)) &amp;gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;) | (&lt;SPAN style="color: #0433ff;"&gt;%index&lt;/SPAN&gt;(&amp;amp;sdate2,&lt;SPAN style="color: #0433ff;"&gt;%str&lt;/SPAN&gt;(/)) &amp;gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate2= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(inputn(&amp;amp;sdate2,mmddyy10.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%else&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;%if&lt;SPAN style="color: #000000;"&gt; ( &lt;/SPAN&gt;%length&lt;SPAN style="color: #000000;"&gt;(&amp;amp;sdate2)=&lt;/SPAN&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; ) &lt;/SPAN&gt;%then&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;%do&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate2= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(inputn(01&amp;amp;sdate2,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate2= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(intnx(month,&amp;amp;sdate2,0,end));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; ( &lt;SPAN style="color: #0433ff;"&gt;%length&lt;/SPAN&gt;(&amp;amp;sdate2)=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt; | &lt;SPAN style="color: #0433ff;"&gt;%length&lt;/SPAN&gt;(&amp;amp;sdate2)=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;9&lt;/STRONG&gt;&lt;/SPAN&gt; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate2= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(inputn(&amp;amp;sdate2,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; ( &lt;SPAN style="color: #0433ff;"&gt;%length&lt;/SPAN&gt;(&amp;amp;sdate2)=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate2= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(inputn(31DEC&amp;amp;sdate2,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; sdate2=&lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(year(&amp;amp;sdate2));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;*Determine loop frequency parameters;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%if&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;%eval&lt;SPAN style="color: #000000;"&gt;(&amp;amp;n)= &lt;/SPAN&gt;&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;%then&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;%let&lt;SPAN style="color: #000000;"&gt; n= &amp;amp;s;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* if n blank use 1 period (=&amp;amp;s) assumption;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; freq=year;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* year frequency case;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; Date variable: &amp;amp;date year_date: &amp;amp;year_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; Start and end dates: &amp;amp;start_date &amp;amp;end_date // &amp;amp;sdate1 &amp;amp;sdate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(putn(&amp;amp;sdate1,date9.)) &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(putn(&amp;amp;sdate2,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; Freq: &amp;amp;freq s: &amp;amp;s n: &amp;amp;n;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* Preliminary date setting for each iteration/loop;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* First end date (idate2) is n periods after the start date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; idate2= &lt;SPAN style="color: #0433ff;"&gt;%eval&lt;/SPAN&gt;(&amp;amp;sdate1+(&amp;amp;n-1));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; idate2= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(intnx(&amp;amp;freq,&amp;amp;sdate1,(&amp;amp;n-1),end));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; idate1= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(intnx(&amp;amp;freq,&amp;amp;idate2,-&amp;amp;n+1,begin));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; idate1= &lt;SPAN style="color: #0433ff;"&gt;%eval&lt;/SPAN&gt;(&amp;amp;idate2-&amp;amp;n+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; First loop: &amp;amp;idate1 -- &amp;amp;idate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; Loop through: &amp;amp;sdate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; (&amp;amp;idate2 &amp;gt; &amp;amp;sdate2) &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%do&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* Dates are not acceptable-- show problem, do not run loop;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; PROBLEM-- end date for loop exceeds range : ( &amp;amp;idate2 &amp;gt; &amp;amp;sdate2 );&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%else&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0433ff;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;; &lt;/SPAN&gt;*Dates are accepted-- run loops;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; jj=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%do&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%while&lt;/SPAN&gt;(&amp;amp;idate2 &amp;lt;= &amp;amp;sdate2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; jj=&lt;SPAN style="color: #0433ff;"&gt;%eval&lt;/SPAN&gt;(&amp;amp;jj+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;*Define loop start date (idate1) based on inherited end date (idate2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%do&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; idate1= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(intnx(&amp;amp;freq,&amp;amp;idate2,-&amp;amp;n+1,begin));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; date1c= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(putn(&amp;amp;idate1,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; date2c= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(putn(&amp;amp;idate2,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%do&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; idate1= &lt;SPAN style="color: #0433ff;"&gt;%eval&lt;/SPAN&gt;(&amp;amp;idate2-&amp;amp;n+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; date1c= &amp;amp;idate1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; date2c= &amp;amp;idate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;%end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; idate1= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(max(&amp;amp;sdate1,&amp;amp;idate1));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; Loop: &amp;amp;jj -- &amp;amp;date1c &amp;amp;date2c;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;jj -- &amp;amp;idate1 &amp;amp;idate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;proc datasets nolist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;delete _outest_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;***** analysis code here -- for each loop;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* noprint to just make output set;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; noprint= noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%upcase&lt;/SPAN&gt;(®print) = yes | &lt;SPAN style="color: #0433ff;"&gt;%upcase&lt;/SPAN&gt;(®print) = print &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; noprint= ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;proc reg data=&amp;amp;data&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;outest=_outest_ds edf&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&amp;amp;noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;where &amp;amp;date between &amp;amp;idate1 and &amp;amp;idate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;model &amp;amp;model_equation;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&amp;amp;by_id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* Add loop date range variables to output set;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;data _outest_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;set _outest_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;regobs= _p_ + _edf_; %&lt;/SPAN&gt;* number of observations in regression;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;date1= &amp;amp;idate1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;date2= &amp;amp;idate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; format date1 date2 &lt;SPAN style="color: #009193;"&gt;date9.&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* Append results;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;proc datasets nolist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;append base=_all_ds data=_outest_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* Set next loop end date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; idate2= &lt;SPAN style="color: #0433ff;"&gt;%sysfunc&lt;/SPAN&gt;(intnx(&amp;amp;freq,&amp;amp;idate2,&amp;amp;s,end));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%if&lt;/SPAN&gt; &amp;amp;year_date=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; idate2= &lt;SPAN style="color: #0433ff;"&gt;%eval&lt;/SPAN&gt;(&amp;amp;idate2+&amp;amp;s);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;; &lt;/SPAN&gt;*% end of loop;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #000000;"&gt;%&lt;/SPAN&gt;* Save outout set to desired location;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;data &amp;amp;out_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;set _all_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;proc sort data=&amp;amp;out_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;by &amp;amp;id date2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #008f00;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;; %&lt;/SPAN&gt;* end for date check pass section;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;print&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;data&lt;/SPAN&gt;=mylib1.proj1(rename= (MSCINordicLV=beta1 MSCINordicSV=beta2 SandPSwedenSG=beta3 CreditSuiseeHY=beta4 EcapEurpoCorp=beta5 lag1Optimus=beta6));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;by&lt;/SPAN&gt; date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;id&lt;/SPAN&gt; date1 date2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;var&lt;/SPAN&gt; rmse beta1 beta2 beta3 beta4 beta5 beta6 rsq regobs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="color: #000000; font-size: 12pt;"&gt;&lt;STRONG&gt;LOG error information:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="color: #000000; font-size: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="color: #000000; font-size: 12pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;160&amp;nbsp; data mylib1.proj;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier; line-height: 1.5em; font-size: 14pt;"&gt;161&amp;nbsp; set mylib1.myseries(keep= date Optimus MSCINordicLV MSCINordicSV SandPSwedenSG CreditSuisseHY&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;161! EcapEuroCorp lag1Optimus);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;162&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;NOTE: There were 1595 observations read from the data set MYLIB1.MYSERIES.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;NOTE: The data set MYLIB1.PROJ has 1595 observations and 8 variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;NOTE: DATA statement used (Total process time):&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt; line-height: 1.5em;"&gt;163&amp;nbsp; %macro rollingreg&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;164&amp;nbsp; (data=mylib1.proj ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;165&amp;nbsp; out_ds=mylib1.proj1 ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;166&amp;nbsp; model_equation= Optimus= MSCINordicLV MSCINordicSV SandPSwedenSG CreditSuisseHY EcapEuroCorp&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;166! lag1Optimus / noint,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;167&amp;nbsp; id= , date=date ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;168&amp;nbsp; start_date=1/10/7 ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;169&amp;nbsp; end_date=8/11/13 ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;170&amp;nbsp; freq=month, s=1, n=12,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;171&amp;nbsp; regprint=noprint);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;172&amp;nbsp; %* Start with empty output data sets;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;173&amp;nbsp; proc datasets nolist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;174&amp;nbsp; delete _all_ds _outest_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;175&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;176&amp;nbsp; * Prepare input data for by-id-date use;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;177&amp;nbsp; proc sort data=&amp;amp;data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;178&amp;nbsp; by &amp;amp;id &amp;amp;date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;179&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;180&amp;nbsp; %* Set the 'by-id' variable;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;181&amp;nbsp; %let by_id= ; *blank default, no by variable;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;182&amp;nbsp; %if %length(&amp;amp;id) &amp;gt; 0 %then %let by_id= by &amp;amp;id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;183&amp;nbsp; %* Determine date range variables;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;184&amp;nbsp; %if %lowcase(%substr(&amp;amp;date,1,4))= year %then %let year_date=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;185&amp;nbsp; %else %let year_date=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;186&amp;nbsp; %let sdate1 = &amp;amp;start_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;187&amp;nbsp; %let sdate2 = &amp;amp;end_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;188&amp;nbsp; %* Make start and end date if missing;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;189&amp;nbsp; %if &amp;amp;start_date = %str() | &amp;amp;end_date = %str() %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;190&amp;nbsp; proc sql noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;191&amp;nbsp; create table _dx1 as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;192&amp;nbsp; select min(&amp;amp;date) as min_date, max(&amp;amp;date) as max_date&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;193&amp;nbsp; from &amp;amp;data where not missing(&amp;amp;date);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;194&amp;nbsp; select min_date into : min_date from _dx1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;195&amp;nbsp; select max_date into : max_date from _dx1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;196&amp;nbsp; quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;197&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;198&amp;nbsp; %* SDATE1 and SDATE2 put in sas date number form (1/1/1960=0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;199&amp;nbsp; %if &amp;amp;sdate1 = %str() %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;200&amp;nbsp; %let sdate1= &amp;amp;min_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;201&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;202&amp;nbsp; %else %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;203&amp;nbsp; %if (%index(&amp;amp;sdate1,%str(-)) &amp;gt; 1) | (%index(&amp;amp;sdate1,%str(/)) &amp;gt; 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;204&amp;nbsp; %then %let sdate1= %sysfunc(inputn(&amp;amp;sdate1,mmddyy10.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;205&amp;nbsp; %else %if ( %length(&amp;amp;sdate1)=7 )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;206&amp;nbsp; %then %let sdate1= %sysfunc(inputn(01&amp;amp;sdate1,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;207&amp;nbsp; %else %if ( %length(&amp;amp;sdate1)=8 | %length(&amp;amp;sdate1)=9 )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;208&amp;nbsp; %then %let sdate1= %sysfunc(inputn(&amp;amp;sdate1,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;209&amp;nbsp; %else %if ( %length(&amp;amp;sdate1)=4 )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;210&amp;nbsp; %then %let sdate1= %sysfunc(inputn(01JAN&amp;amp;sdate1,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;211&amp;nbsp; %if &amp;amp;year_date=1 %then %let sdate1=%sysfunc(year(&amp;amp;sdate1));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;212&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;213&amp;nbsp; %if &amp;amp;sdate2 = %str() %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;214&amp;nbsp; %let sdate2= &amp;amp;max_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;215&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;216&amp;nbsp; %else %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;217&amp;nbsp; %if (%index(&amp;amp;sdate2,%str(-)) &amp;gt; 1) | (%index(&amp;amp;sdate2,%str(/)) &amp;gt; 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;218&amp;nbsp; %then %let sdate2= %sysfunc(inputn(&amp;amp;sdate2,mmddyy10.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;219&amp;nbsp; %else %if ( %length(&amp;amp;sdate2)=7 ) %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;220&amp;nbsp; %let sdate2= %sysfunc(inputn(01&amp;amp;sdate2,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;221&amp;nbsp; %let sdate2= %sysfunc(intnx(month,&amp;amp;sdate2,0,end));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;222&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;223&amp;nbsp; %else %if ( %length(&amp;amp;sdate2)=8 | %length(&amp;amp;sdate2)=9 )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;224&amp;nbsp; %then %let sdate2= %sysfunc(inputn(&amp;amp;sdate2,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;225&amp;nbsp; %else %if ( %length(&amp;amp;sdate2)=4 )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;226&amp;nbsp; %then %let sdate2= %sysfunc(inputn(31DEC&amp;amp;sdate2,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;227&amp;nbsp; %if &amp;amp;year_date=1 %then %let sdate2=%sysfunc(year(&amp;amp;sdate2));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;228&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;229&amp;nbsp; %*Determine loop frequency parameters;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;230&amp;nbsp; %if %eval(&amp;amp;n)= 0 %then %let n= &amp;amp;s;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;231&amp;nbsp; %* if n blank use 1 period (=&amp;amp;s) assumption;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;232&amp;nbsp; %if &amp;amp;year_date=1 %then %let freq=year;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;233&amp;nbsp; %* year frequency case;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;234&amp;nbsp; %put Date variable: &amp;amp;date year_date: &amp;amp;year_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;235&amp;nbsp; %put Start and end dates: &amp;amp;start_date &amp;amp;end_date // &amp;amp;sdate1 &amp;amp;sdate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;236&amp;nbsp; %if &amp;amp;year_date=0 %then&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;237&amp;nbsp; %put %sysfunc(putn(&amp;amp;sdate1,date9.)) %sysfunc(putn(&amp;amp;sdate2,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;238&amp;nbsp; %put Freq: &amp;amp;freq s: &amp;amp;s n: &amp;amp;n;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;239&amp;nbsp; %* Preliminary date setting for each iteratio&lt;/SPAN&gt;n/loop;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;240&amp;nbsp; %* First end date (idate2) is n periods after the start date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;241&amp;nbsp; %if &amp;amp;year_date=1 %then %let idate2= %eval(&amp;amp;sdate1+(&amp;amp;n-1));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;242&amp;nbsp; %else %let idate2= %sysfunc(intnx(&amp;amp;freq,&amp;amp;sdate1,(&amp;amp;n-1),end));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;243&amp;nbsp; %if &amp;amp;year_date=0 %then %let idate1= %sysfunc(intnx(&amp;amp;freq,&amp;amp;idate2,-&amp;amp;n+1,begin));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;244&amp;nbsp; %else %let idate1= %eval(&amp;amp;idate2-&amp;amp;n+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;245&amp;nbsp; %put First loop: &amp;amp;idate1 -- &amp;amp;idate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;246&amp;nbsp; %put Loop through: &amp;amp;sdate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;247&amp;nbsp; %if (&amp;amp;idate2 &amp;gt; &amp;amp;sdate2) %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;248&amp;nbsp; %* Dates are not acceptable-- show problem, do not run loop;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;249&amp;nbsp; %put PROBLEM-- end date for loop exceeds range : ( &amp;amp;idate2 &amp;gt; &amp;amp;sdate2 );&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;250&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;251&amp;nbsp; %else %do; *Dates are accepted-- run loops;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;252&amp;nbsp; %let jj=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;253&amp;nbsp; %do %while(&amp;amp;idate2 &amp;lt;= &amp;amp;sdate2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;254&amp;nbsp; %let jj=%eval(&amp;amp;jj+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;255&amp;nbsp; %*Define loop start date (idate1) based on inherited end date (idate2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;256&amp;nbsp; %if &amp;amp;year_date=0 %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;257&amp;nbsp; %let idate1= %sysfunc(intnx(&amp;amp;freq,&amp;amp;idate2,-&amp;amp;n+1,begin));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;258&amp;nbsp; %let date1c= %sysfunc(putn(&amp;amp;idate1,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;259&amp;nbsp; %let date2c= %sysfunc(putn(&amp;amp;idate2,date9.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;260&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;261&amp;nbsp; %if &amp;amp;year_date=1 %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;262&amp;nbsp; %let idate1= %eval(&amp;amp;idate2-&amp;amp;n+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;263&amp;nbsp; %let date1c= &amp;amp;idate1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;264&amp;nbsp; %let date2c= &amp;amp;idate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;265&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;266&amp;nbsp; %let idate1= %sysfunc(max(&amp;amp;sdate1,&amp;amp;idate1));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;267&amp;nbsp; %put Loop: &amp;amp;jj -- &amp;amp;date1c &amp;amp;date2c;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;268&amp;nbsp; %put &amp;amp;jj -- &amp;amp;idate1 &amp;amp;idate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;269&amp;nbsp; proc datasets nolist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;270&amp;nbsp; delete _outest_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;271&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;272&amp;nbsp; %***** analysis code here -- for each loop;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;273&amp;nbsp; %* noprint to just make output set;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;274&amp;nbsp; %let noprint= noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;275&amp;nbsp; %if %upcase(®print) = yes | %upcase(®print) = print %then %let noprint= ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;276&amp;nbsp; proc reg data=&amp;amp;data&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;277&amp;nbsp; outest=_outest_ds edf&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;278&amp;nbsp; &amp;amp;noprint;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;279&amp;nbsp; where &amp;amp;date between &amp;amp;idate1 and &amp;amp;idate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;280&amp;nbsp; model &amp;amp;model_equation;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;281&amp;nbsp; &amp;amp;by_id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;282&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;283&amp;nbsp; %* Add loop date range variables to output set;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;284&amp;nbsp; data _outest_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;285&amp;nbsp; set _outest_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;286&amp;nbsp; regobs= _p_ + _edf_; %* number of observations in regression;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;287&amp;nbsp; date1= &amp;amp;idate1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;288&amp;nbsp; date2= &amp;amp;idate2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;289&amp;nbsp; %if &amp;amp;year_date=0 %then format date1 date2 date9.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;290&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;291&amp;nbsp; %* Append results;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;292&amp;nbsp; proc datasets nolist;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;293&amp;nbsp; append base=_all_ds data=_outest_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;294&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;295&amp;nbsp; %* Set next loop end date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;296&amp;nbsp; %if &amp;amp;year_date=0 %then %let idate2= %sysfunc(intnx(&amp;amp;freq,&amp;amp;idate2,&amp;amp;s,end));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;297&amp;nbsp; %else %if &amp;amp;year_date=1 %then %let idate2= %eval(&amp;amp;idate2+&amp;amp;s);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;298&amp;nbsp; %end; *% end of loop;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;299&amp;nbsp; %* Save outout set to desired location;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;300&amp;nbsp; data &amp;amp;out_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;301&amp;nbsp; set _all_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;302&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;303&amp;nbsp; proc sort data=&amp;amp;out_ds;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;304&amp;nbsp; by &amp;amp;id date2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;305&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;306&amp;nbsp; %end; %* end for date check pass section;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;307&amp;nbsp; %mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;308&amp;nbsp; proc print data=mylib1.proj1(rename= (MSCINordicLV=beta1 MSCINordicSV=beta2 SandPSwedenSG=beta3&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;308! CreditSuiseeHY=beta4 EcapEurpoCorp=beta5 lag1Optimus=beta6));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;ERROR: File MYLIB1.PROJ1.DATA does not exist.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 14pt;"&gt;309&amp;nbsp; by date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;310&amp;nbsp; id date1 date2;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;311&amp;nbsp; var rmse beta1 beta2 beta3 beta4 beta5 beta6 rsq regobs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;312&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 8px; font-family: Courier;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 11:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rolling-regression-with-macro/m-p/173668#M44711</guid>
      <dc:creator>katya</dc:creator>
      <dc:date>2014-04-09T11:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: rolling regression with macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rolling-regression-with-macro/m-p/173669#M44712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It appears you are missing the %rollingreg statement to execute the macro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 14:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rolling-regression-with-macro/m-p/173669#M44712</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2014-04-09T14:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: rolling regression with macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/rolling-regression-with-macro/m-p/173670#M44713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Debugging a macro is not fun, but here are some steps that can help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Turn on Options SYMBOLGEN MPRINT;&lt;/P&gt;&lt;P&gt;This will allow you to see what's going on in your code.&lt;/P&gt;&lt;P&gt;2. Add selective %PUT/PUT statements as required to see variables values throughout the process.&lt;/P&gt;&lt;P&gt;3. Move the %mend up to your first "point" in the macro where you can safely run it and test it in iterations. Get one step working and then work on the next step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionally, when first writing a macro it helps to first have working code that is non-macrotized and start from there. Always test changes in as small a batch as you can. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 15:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/rolling-regression-with-macro/m-p/173670#M44713</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-04-09T15:24:01Z</dc:date>
    </item>
  </channel>
</rss>

