- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have this macro
%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
This i giving me error
MPRINT(__CODE): action runTimeCode / table={ caslib="CASUSER(swkuma)", name="PRICEDATA" } objOut={ { table={ caslib="CASUSER",
name="outStatTemp" , replace="true" }, objRef='outStat' } } , { table={ caslib="CASUSER", name="outFcastTemp" , replace="true" },
objRef='outFcast' } seasonality=12 timeId={name='date' , FORMAT="_DATA_"} interval="Month" nlFormat=true series={'sale'}
require={{pkg='TSM'}} code=' declare object myModel(TSM); declare object mySpec(ARIMASpec); rc =
mySpec.Open(); ma[1] = 1; rc = mySpec.AddMAPoly(ma); rc = mySpec.SetOption("noint",1);
rc = mySpec.SetOption("method","CLS"); rc = mySpec.close(); rc =
myModel.Initialize(mySpec); rc = myModel.SetY(sale); rc = myModel.SetOption('lead', 12); rc =
myModel.SetOption("alpha",0.05); rc = myModel.Run(); declare object outFcast(TSMFor); rc =
outFcast.Collect(myModel); declare object outStat(TSMSTAT); rc = outStat.Collect(myModel);
';
ERROR: A name token was expected
ERROR: action runTimeCode / table = { caslib = 'CASUSER(swkuma)' , n
ERROR: ame = 'PRICEDATA' } objOut = { { table = { caslib = 'CASUSER'
ERROR: , name = 'outStatTemp' , replace = 'true' } , objRef = 'outS
ERROR: tat' } } , { table = { caslib = 'CASUSER' , name = 'outFcastT
ERROR: emp' , replace = 'true' } , objRef = 'outFcast' } seasonality
ERROR: = 12 timeId = { name = 'date' , FORMAT = '_DATA_' } interval
ERROR: = 'Month' nlFormat = TRUE series = { 'sale' } require = { {
ERROR: pkg = 'TSM' } } code = ' declare object myModel(TS
ERROR: M); declare object mySpec(ARIMASpec); r
ERROR: c = mySpec.Open(); ma[1] = 1; rc =
ERROR: mySpec.AddMAPoly(ma); rc = mySpec.SetOption("noint
ERROR: ",1); rc = mySpec.SetOption("method","CLS");
ERROR: rc = mySpec.close();
ERROR: rc = myModel.Initialize(mySpec); rc = myModel.Set
ERROR: Y(sale); rc = myModel.SetOption(' lead ', 12);
ERROR: rc = myModel.SetOption("alpha",0.05); rc =
ERROR: myModel.Run(); declare object outFcast(TSMFor)
ERROR: ; rc = outFcast.Collect(myModel);
ERROR: declare object outStat(TSMSTAT); rc = ou
ERROR: tStat.Collect(myModel); ' ;
ERROR: ^
NOTE: The submitted statements have been canceled.
Please help me to debug why this is coming and how to resolve this . Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
MPRINT(__CODE): proc cas;
MPRINT(__CODE): session CASAUTO;
MPRINT(__CODE): loadactionset "timeData";
NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks.
NOTE: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a
quoted string and the succeeding identifier is recommended.
MPRINT(__CODE): action runTimeCode / table={ caslib="CASUSER(swkuma)", name="PRICEDATA" } objOut={ { table={ caslib="CASUSER",
name="outStatTemp" , replace="true" }, objRef='outStat' } } seasonality=12 timeId={name='date' , FORMAT="_DATA_"} interval="Month"
nlFormat=true series={'sale'} require={{pkg='TSM'}} code=' declare object myModel(TSM); declare object
mySpec(ARIMASpec); rc = mySpec.Open(); array ma[2]/nosymbols; ma[1] = 1; ma[2]
= 2; rc = mySpec.AddMAPoly(ma); rc = mySpec.SetOption("noint",1); rc =
mySpec.SetOption("method","CLS"); rc = mySpec.close(); rc =
myModel.Initialize(mySpec); rc = myModel.SetY(sale); rc = myModel.SetOption('lead', 12); rc =
myModel.SetOption("alpha",0.05); rc = myModel.Run(); declare object outStat(TSMSTAT);
rc = outStat.Collect(myModel); ';
ERROR: A name token was expected
ERROR: action runTimeCode / table = { caslib = 'CASUSER(swkuma)' , n
ERROR: ame = 'PRICEDATA' } objOut = { { table = { caslib = 'CASUSER'
ERROR: , name = 'outStatTemp' , replace = 'true' } , objRef = 'outS
ERROR: tat' } } seasonality = 12 timeId = { name = 'date' , FORMAT =
ERROR: '_DATA_' } interval = 'Month' nlFormat = TRUE series = { 'sa
ERROR: le' } require = { { pkg = 'TSM' } } code = ' decla
ERROR: re object myModel(TSM); declare object mySpec(ARIM
ERROR: ASpec); rc = mySpec.Open(); array ma[2]
ERROR: /nosymbols; ma[1] = 1; ma[2] =
ERROR: 2; rc = mySpec.AddMAPoly(ma); rc = mySp
ERROR: ec.SetOption("noint",1); rc = mySpec.SetOption("me
ERROR: thod","CLS"); rc = mySpec.close();
ERROR: rc = myModel.Initialize(mySpec);
ERROR: rc = myModel.SetY(sale); rc = myModel.SetOption
ERROR: (' lead ', 12); rc = myModel.SetOption("alpha",0.0
ERROR: 5); rc = myModel.Run(); dec
ERROR: lare object outStat(TSMSTAT); rc = outStat.Collect
ERROR: (myModel); ' ;
ERROR: ^
NOTE: The submitted statements have been canceled.
MPRINT(__CODE): run;
MPRINT(__CODE): ;
NOTE: PROCEDURE CAS used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
"NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks."
If you can't find the problem in the code, try to strip down the macro until it works, and than add code part by part until you find the problem.