<?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: Looping for time series model in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Looping-for-time-series-model/m-p/900963#M4740</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;This is the dumbest and slowest way of doing it.&lt;/P&gt;
&lt;P&gt;Let us know if you need something more performant, more concise and more smart!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
 set sashelp.pricedata;
 where region=3;
 where also line=4;
 where also product=13;
run;

PROC SQL noprint;
 create table varnamesarima as
 select *
 from dictionary.columns
 where libname='WORK' and memname='ABC' 
       and type='num' and name NOT IN ('date','cost','region','line','product');
QUIT;

data _NULL_;
 if 0 then set varnamesarima nobs=count;
 call symputx('numbervars',put(count,12.));
 STOP;
run;
%PUT &amp;amp;=numbervars;

%MACRO DO_BRANCH;
%do i=1 %to &amp;amp;numbervars;

data _NULL_;
 set varnamesarima(firstobs=&amp;amp;i. obs=&amp;amp;i.);
 call symputx('currentvar',name);
run;
%PUT §§§§§§§§§§ CURRENT VAR §§§§§§§§§§;
%PUT &amp;amp;=currentvar;
%PUT §§§§§§§§§§ CURRENT VAR §§§§§§§§§§;
 
proc timeseries data=Work.abc seasonality=12 plots=(series corr);
 id date interval=month;
 var &amp;amp;currentvar. / accumulate=none transform=none dif=0 sdif=0;
run;
 
proc arima data=Work.abc;
 identify var=&amp;amp;currentvar.;                     run;
/*** for multiplicative SARIMA model ***/
 estimate q=(1) p=(1)(12) noconstant method=ml; run;
QUIT;
 
%end;
%MEND DO_BRANCH;
%DO_BRANCH
QUIT;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
    <pubDate>Tue, 31 Oct 2023 20:21:47 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2023-10-31T20:21:47Z</dc:date>
    <item>
      <title>Looping for time series model</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Looping-for-time-series-model/m-p/900023#M4738</link>
      <description>&lt;P&gt;Hey all, I had simulation data with 500 column as replication data, and 1500 rows as number of sample size in a excel file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wish to ask how do i need to do it in loop which ask sas to read the first column then carry on the proc arima and get the AIC, then loop with second column and so on...&amp;nbsp;&lt;/P&gt;&lt;P&gt;and wish to have all the AIC values in a dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can some one please help me on this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;ods noproctitle;&lt;/DIV&gt;&lt;DIV&gt;ods graphics / imagemap=on;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc sort data=WORK.IMPORT1 out=Work.preProcessedData;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;by Time;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;%MACRO DO_BRANCH;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%do i=1 %to 500;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;proc timeseries data=Work.preProcessedData seasonality=7 plots=(series corr);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;id Time interval=day;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var Data&amp;amp;i / accumulate=none transform=none dif=0 sdif=0;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;proc arima data=Work.preProcessedData;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;identify var=Data&amp;amp;i;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;/*** for multiplicative SARIMA model ***/&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;estimate q=(1) p=(1)(7) noconstant method=ml;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;%end;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;%MEND DO_BRANCH;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;proc delete data=Work.preProcessedData;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;</description>
      <pubDate>Wed, 25 Oct 2023 18:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Looping-for-time-series-model/m-p/900023#M4738</guid>
      <dc:creator>aaileng</dc:creator>
      <dc:date>2023-10-25T18:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: Looping for time series model</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Looping-for-time-series-model/m-p/900024#M4739</link>
      <description>&lt;P&gt;I'm not an expert on PROC TIMESERIES but you can list multiple variables in the VAR statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is also this, scroll down to the section "The BY way for many models", which talks about PROC REG but the exact same method using a BY statement should work for PROC TIMESERIES and/or PROC ARIMA&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/iml/2017/02/13/run-1000-regressions.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 19:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Looping-for-time-series-model/m-p/900024#M4739</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-25T19:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Looping for time series model</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Looping-for-time-series-model/m-p/900963#M4740</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;This is the dumbest and slowest way of doing it.&lt;/P&gt;
&lt;P&gt;Let us know if you need something more performant, more concise and more smart!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data abc;
 set sashelp.pricedata;
 where region=3;
 where also line=4;
 where also product=13;
run;

PROC SQL noprint;
 create table varnamesarima as
 select *
 from dictionary.columns
 where libname='WORK' and memname='ABC' 
       and type='num' and name NOT IN ('date','cost','region','line','product');
QUIT;

data _NULL_;
 if 0 then set varnamesarima nobs=count;
 call symputx('numbervars',put(count,12.));
 STOP;
run;
%PUT &amp;amp;=numbervars;

%MACRO DO_BRANCH;
%do i=1 %to &amp;amp;numbervars;

data _NULL_;
 set varnamesarima(firstobs=&amp;amp;i. obs=&amp;amp;i.);
 call symputx('currentvar',name);
run;
%PUT §§§§§§§§§§ CURRENT VAR §§§§§§§§§§;
%PUT &amp;amp;=currentvar;
%PUT §§§§§§§§§§ CURRENT VAR §§§§§§§§§§;
 
proc timeseries data=Work.abc seasonality=12 plots=(series corr);
 id date interval=month;
 var &amp;amp;currentvar. / accumulate=none transform=none dif=0 sdif=0;
run;
 
proc arima data=Work.abc;
 identify var=&amp;amp;currentvar.;                     run;
/*** for multiplicative SARIMA model ***/
 estimate q=(1) p=(1)(12) noconstant method=ml; run;
QUIT;
 
%end;
%MEND DO_BRANCH;
%DO_BRANCH
QUIT;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 20:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Looping-for-time-series-model/m-p/900963#M4740</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-10-31T20:21:47Z</dc:date>
    </item>
  </channel>
</rss>

