Thank you so much! I've used much of your code to adapt it to my specific case, which uses external forecast. I'm posting my code for future users, in search of solutions! options casdatalimit=ALL;
cas mysession sessopts=(caslib=casuser timeout=1800);
caslib _all_ assign;
caslib query datasource=(srctype="path") path="/sasdata/Stl_analysis/query/"
local;
libname query cas caslib=query;
proc cas;
table.fileInfo result=fileList / kbytes=true;
do row over fileList.FileInfo;
print row.name;
table.loadtable / path=row.name, caslib='query', casout={caslib='query',
name=substr(row.name , 1, index(row.name, '.')-1), replace=true};
end;
quit;
/* test DS */
data casuser.test;
set query.nn_rciv_g_preds_hist;
keep date pred_: ae_: stl_tgt_ricciv_all P_rciv_ens;
rename P_rciv_ens=prediction;
rename stl_tgt_ricciv_all = target;
run;
proc tsmodel
data=casuser.test outlog=casuser.outlog
logcontrol=(error=keep warning=keep note=keep none=keep)
outobj=(
outfor=casuser.forecast
outstat=casuser.stats
outest =casuser.estimation
);
id date interval=day setmissing=missing;
var ae_: pred_:;
print outlog;
require atsm ;
require tsm;
submit;
/* Initialize the data frame with Y-series and independent variables */
declare object dataFrame(tsdf);
rc = dataFrame.initialize();
rc = dataFrame.AddY(pred_globale_m1_1g);
rc = dataFrame.AddY(pred_globale_m1_2g);
rc = dataFrame.AddY(ae_globale_m1_1g);
rc = dataFrame.AddY(ae_globale_m1_2g);
rc = dataFrame.addX(date,'REQUIRED','YES');
/* object for collecting results */
declare object outstat(outstat);
declare object outfor(outfor);
declare object outest(outest);
/* Specify external models to be imported */
declare object ext_glob_m1_1g(exmspec);
declare object ext_glob_m1_2g(exmspec);
/* object responsible for combining models */
declare object ensemble(COMBSPEC);
/* object responsible for running forecast*/
declare object makeForecast(FORENG);
/* TSM object populated with external series*/
declare object tsm_glob_m1_1g(tsm);
declare object tsm_glob_m1_2g(tsm);
/* for each external model we define the array*/
/* containing Prediction and Absolute Error */
rc = ext_glob_m1_1g.Open();
rc = ext_glob_m1_1g.SetOption('Predict', 'pred_globale_m1_1g' ,'Error', 'ae_globale_m1_1g');
rc = ext_glob_m1_1g.Close();
rc = ext_glob_m1_2g.Open();
rc = ext_glob_m1_2g.SetOption('Predict', 'pred_globale_m1_2g', 'Error', 'ae_globale_m1_2g');
rc = ext_glob_m1_2g.Close();
/* Initialization and run of first model */
rc = tsm_glob_m1_1g.Initialize(ext_glob_m1_1g);
rc = tsm_glob_m1_1g.AddExternal(pred_globale_m1_1g, 'predict');
rc = tsm_glob_m1_1g.AddExternal(ae_globale_m1_1g, 'error');
rc = tsm_glob_m1_1g.Run();
/* Initialization and run of second model */
rc = tsm_glob_m1_2g.Initialize(ext_glob_m1_2g);
rc = tsm_glob_m1_2g.AddExternal(pred_globale_m1_2g, 'predict');
rc = tsm_glob_m1_2g.AddExternal(ae_globale_m1_2g, 'error');
rc = tsm_glob_m1_2g.Run();
/* Combspec object preparation */
rc=ensemble.Open(2);
rc=ensemble.AddFrom(tsm_glob_m1_1g);
rc=ensemble.AddFrom(tsm_glob_m1_2g);
rc=ensemble.SetOption('WEIGHT', 'RANKWGT');
rc=ensemble.Close();
/* FORENG object execution */
rc=makeforecast.initialize(dataFrame);
rc=makeForecast.addFrom(ensemble);
rc=makeForecast.SetOption('CRITERION', 'MAE');
rc=makeForecast.run();
rc =outfor.collect(makeForecast, 'ALL');
rc =outest.collect(makeForecast);
rc =outest.collect(makeforecast);
endsubmit;
quit;
/* Print the results */
proc print data=casuser.estimation;title 'OUTEST=';run;
proc print data=casuser.forecast;title 'OUTFOR=';run; As you can see I've used object both from atsm package and from the tsm package to deal with external models ( Neural Net models) Thanks again
... View more