Use this little icon :
to paste your code like it should be:
%macro run_cas_ma;
libname _tmpcas_ cas caslib="CASUSER";
proc cas;
/* Ensure that the session is set correctly */
session %sysfunc(getlsessref(&dataset_lib));
/* Load the necessary action set */
loadactionset %sysfunc(quote(timeData));
action runTimeCode /
table={
caslib=%sysfunc(quote(%sysfunc(getlcaslib(&dataset_lib))))%str(,)
name=%sysfunc(quote(&dataset_name))
} /* Table definition comes first */
objOut={
{
table={
caslib=%sysfunc(quote(%sysfunc(getlcaslib(_tmpcas_))))%str(,)
name=%qsysfunc(quote(outStatTemp)) %str(,)
replace=%sysfunc(quote(true))
}%str(,)
objRef=%str('outStat')
}
}
/* Conditionally add forecast output if plotForecastViya is set to 1 */
%if &plotForecastViya = 1 %then %do;
%str(,)
{
table={
caslib=%sysfunc(quote(%sysfunc(getlcaslib(_tmpcas_))))%str(,)
name=%sysfunc(quote(outFcastTemp)) %str(,)
replace=%sysfunc(quote(true))
}%str(,)
objRef=%str('outFcast')
}
%end;
seasonality=12
timeId={name=%str('date') %str(,) FORMAT=%sysfunc(quote(_DATA_))}
interval="Month"
nlFormat=true
series={'sale'}
require={{pkg='TSM'}}
code=%str(%')
declare object myModel(TSM);
declare object mySpec(ARIMASpec);
rc = mySpec.Open();
/* Loop to assign values to ma[&i.] */
%do i=1 %to &map.;
ma[&i.] = &i.;
%end;
rc = mySpec.AddMAPoly(ma);
rc = mySpec.SetOption("noint",1);
rc = mySpec.SetOption("method","CLS");
rc = mySpec.close();
/* Initialize the model */
rc = myModel.Initialize(mySpec);
rc = myModel.SetY(&dependVariable);
rc = myModel.SetOption('lead', &forecastPeriods);
rc = myModel.SetOption("alpha",0.05);
rc = myModel.Run();
/* Collect forecast if plotForecastViya is set to 1 */
%if &plotForecastViya = 1 %then %do;
declare object outFcast(TSMFor);
rc = outFcast.Collect(myModel);
%end;
declare object outStat(TSMSTAT);
rc = outStat.Collect(myModel);
%str(%');
run;
%mend run_cas_ma;
%run_cas_ma
First of all: writing a macro without parameters is bad programming practice.
Second thing what are:
timeData, outFcastTemp are those mcarovariables ? or constant texts ?
Where the &map. macrovariabel comes from?
where is the definition of array "ma", that one used here:
%do i=1 %to &map.;
ma[&i.] = &i.;
%end;
?
Mprint in the text you pasted comes from macro: __CODE, where is that macro defined?
Assigning TRUE/FALSE values to option:
replace=%sysfunc(quote(true))
I think should be like this:
replace=1
or
replace=True
(see example: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/caspg/p1668p6hhivls3n11q05kk6h1zgj.htm)
Single-quotes embedded improperly in "code":
Etc., etc., etc.
... View more