<?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: Forecast with lagged dependent variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805258#M317194</link>
    <description>&lt;P&gt;I'm on version, 9.04 according to the statement below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%PUT &amp;amp;=sysvlong4;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was hoping my objective can be achieved with some other (stats) procedure instead of a data step, since the data step does not seem to remember the prior value of the y_forececast variable.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Mar 2022 13:22:05 GMT</pubDate>
    <dc:creator>dzurov</dc:creator>
    <dc:date>2022-03-31T13:22:05Z</dc:date>
    <item>
      <title>Forecast with lagged dependent variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805127#M317111</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to use a given statistical time series function to forecast a variable (y) from a specific date forward (e.g. starting from April 1st 2021). The y variable has the actual data while y_forecast is the estimate based on a function. The function needs to use the lag of the predicted variable (y_forecast) from&amp;nbsp;April 1st 2021 forward. Also, I need to&amp;nbsp;compare the y_forecast to y and determine the variance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my below attempt I have not been able to generate any values for the forecast period.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data data;
input date date9. y x;
format date date9.;
cards;
26MAR2021 2.41 1.791
27MAR2021 2.34 1.783
28MAR2021 2.46 1.874
29MAR2021 2.52 1.867
30MAR2021 2.55 1.901
31MAR2021 2.50 1.851
01APR2021 2.61 1.920
02APR2021 2.65 1.932
03APR2021 2.69 1.944
04APR2021 2.74 1.951
;
run;
data model;
set data;

x_lag = lag(x);
x_chg = dif(x); 
y_lag = IFN(Date le '31MAR2021'd ,lag(y),lag(y_forecast));
y_chg_lag = IFN(Date le '31MAR2021'd ,lag(y) - lag2(y), lag(y_forecast) - lag2(y_forecast));

bx1 = 0.2;
bx2 = 0.4;
bc0 = 0.1;
by1 = 0.3;

y_forecast = y_lag + bx1 * x_lag * x_chg + bx2 + bc0 + by1 * y_chg_lag;
variance = y - y_forecast;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Any thoughts how to achieve this are appreciated. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 18:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805127#M317111</guid>
      <dc:creator>dzurov</dc:creator>
      <dc:date>2022-03-30T18:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Forecast with lagged dependent variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805154#M317126</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why aren't you using one of the many procedures SAS offers for forecasting (=extrapolating dependent variable time series into the future)?&lt;/P&gt;
&lt;P&gt;Do you have SAS/ETS or SAS Econometrics or Forecast Server or Visual Forecasting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 21:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805154#M317126</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-03-30T21:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Forecast with lagged dependent variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805192#M317151</link>
      <description>I don't believe I have those available.</description>
      <pubDate>Thu, 31 Mar 2022 02:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805192#M317151</guid>
      <dc:creator>dzurov</dc:creator>
      <dc:date>2022-03-31T02:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Forecast with lagged dependent variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805204#M317158</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/410689"&gt;@dzurov&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which version of SAS are you running?&lt;/P&gt;
&lt;P&gt;Submit&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%PUT &amp;amp;=sysvlong4;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to find out (look in the LOG).&lt;BR /&gt;&lt;BR /&gt;If you have SAS 9.4 M&lt;EM&gt;x&lt;/EM&gt; (Maintenance Level &lt;EM&gt;something&lt;/EM&gt;), then submit:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc setinit; run;
proc product_status; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to find out if you have SAS/ETS or SAS Forecast Server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have SAS VIYA (VIYA 3.5 or VIYA 4), then submit :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cas;                 /* connect to CAS session */
 
proc cas;
   getLicensedProductInfo;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to find out if you have SAS/ETS or SAS Econometrics or SAS Visual Forecasting.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Doing the same with a data step will be&amp;nbsp;a pale imitation of real forecasting (where you correctly take autocorrelation into account).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See also this blog :&lt;/P&gt;
&lt;P&gt;How to find release and licensing information in SAS Viya?&lt;BR /&gt;By &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&amp;nbsp;on The DO Loop February 28, 2022&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2022/02/28/release-license-sas-viya.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2022/02/28/release-license-sas-viya.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 06:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805204#M317158</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-03-31T06:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Forecast with lagged dependent variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805258#M317194</link>
      <description>&lt;P&gt;I'm on version, 9.04 according to the statement below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%PUT &amp;amp;=sysvlong4;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was hoping my objective can be achieved with some other (stats) procedure instead of a data step, since the data step does not seem to remember the prior value of the y_forececast variable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 13:22:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805258#M317194</guid>
      <dc:creator>dzurov</dc:creator>
      <dc:date>2022-03-31T13:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: Forecast with lagged dependent variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805261#M317196</link>
      <description>&lt;P&gt;Try something like this ( auto-regression ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc autoreg data=sashelp.citiday;
   model SNYDJCM = / nlag=1 method=ml;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 13:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Forecast-with-lagged-dependent-variable/m-p/805261#M317196</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-03-31T13:30:21Z</dc:date>
    </item>
  </channel>
</rss>

