ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required
我遇到如下错误。
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &N_GROUP
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro ORDERFLOW will stop executing.
当我在没有远程提交的情况下在本地测试它时,它起作用了。但它不适用于 WRDS 服务器。我尝试了很多方法来解决这个问题,但找不到问题所在。
这是我的代码。仅供参考,这是一个更大的试验代码。
%macro orderflow(YYYYMMDD=, CUTOFF=) /des = "Create OrderFlow";
%syslput YYYYMMDD = &YYYYMMDD;
%syslput CUTOFF = &CUTOFF;
%let wrds = wrds.wharton.upenn.edu 4016;
options comamid=TCP;
signon wrds username=_prompt_;
rsubmit;
/* Enter your WRDS institution name and your WRDS username */
options errors=2;
/* STEP 1: RETRIEVE DAILY TRADE AND QUOTE (DTAQ) FILES */
libname nbbo '/wrds/nyse/sasdata/taqms/nbbo';
libname cq '/wrds/nyse/sasdata/taqms/cq';
libname ct '/wrds/nyse/sasdata/taqms/ct';
libname mast '/wrds/nyse/sasdata/taqms/mast';
/* Create StockList each having 100 stocks */
proc sql noprint;
select ceil(count(SYMBOL_ROOT)/&CUTOFF) into :N_GROUP
from mast.mastm_&YYYYMMDD
where LISTED_MARKET in ('A' 'N' 'T' 'Q') /* AMEX, NYSE, NASDAQ */
and TAPE = 'A' /* Common stock */
; quit;
%do i=1 %to &N_GROUP;
%global STOCKLIST&i;
proc sql noprint;
select SYMBOL_ROOT into :STOCKLIST&i separated by '" "'
from mast.mastm_&YYYYMMDD
where LISTED_MARKET in ('A' 'N' 'T' 'Q') /* AMEX, NYSE, NASDAQ */
and TAPE = 'A' /* Common stock */
and monotonic() between &cutoff*(&i-1)+1 and &cutoff*&i
; quit;
/* Retrieve NBBO data */
data DailyNBBO;
/* Enter NBBO file names in YYYYMMDD format for the dates you want */
set nbbo.nbbom_&YYYYMMDD;
/* Enter company tickers you want */
where sym_root in ("&&STOCKLIST&i") and
/* Quotes are retrieved prior to market open time to ensure NBBO
Quotes are available for beginning of the day trades */
(("9:00:00.000000000"t) <= time_m <= ("9:30:00.000000000"t));
format date date9.;
format time_m part_time trf_time TIME20.9;
run;
/* Retrieve Quote data */
data DailyQuote;
/* Enter Quote file names in YYYYMMDD format for the same dates */
set cq.cqm_&YYYYMMDD;
/* Enter the same company tickers as above */
where sym_root in ("&&STOCKLIST&i") and
/* Quotes are retrieved prior to market open time to ensure NBBO
Quotes are available for beginning of the day trades*/
(("9:00:00.000000000"t) <= time_m <= ("9:30:00.000000000"t));
format date date9.;
format time_m part_time trf_time TIME20.9;
run;
/* Retrieve Trade data */
data DailyTrade;
/* Enter Trade file names in YYYYMMDD format for the same dates */
set ct.ctm_&YYYYMMDD;
/* Enter the same company tickers as above */
where sym_root in ("&&STOCKLIST&i") and
/* Retrieve trades during normal market hours */
(("9:30:00.000000000"t) <= time_m <= ("9:30:00.000000000"t));
type='T';
format date date9.;
format time_m part_time trf_time TIME20.9;
run;
/* Download to PC */
proc download data=DailyNBBO out=taq.DailyNBBO_&&YYYYMMDD&i; run;
proc download data=DailyQuote out=taq.DailyQuote_&&YYYYMMDD&i; run;
proc download data=DailyTrade out=taq.DailyTrade_&&YYYYMMDD&i; run;
%end;
%mend orderflow;
%orderflow(YYYYMMDD=20141224,CUTOFF=100);
任何评论表示赞赏。谢谢
此宏在本地机器上构造为 运行,因为它包含 SIGNON 和 RSUBMIT/ENDRSUBMIT 块。
但是您引用的是通过 SQL INTO 子句在远程计算机上创建的宏变量 N_GROUP
。我认为这是错误消息的原因。
在远程机器上将宏定义为 运行 或使用 %SYSRPUT
将宏变量值移回本地机器以便您可以使用它来控制 %DO
循环。
我遇到如下错误。
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &N_GROUP
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro ORDERFLOW will stop executing.
当我在没有远程提交的情况下在本地测试它时,它起作用了。但它不适用于 WRDS 服务器。我尝试了很多方法来解决这个问题,但找不到问题所在。
这是我的代码。仅供参考,这是一个更大的试验代码。
%macro orderflow(YYYYMMDD=, CUTOFF=) /des = "Create OrderFlow";
%syslput YYYYMMDD = &YYYYMMDD;
%syslput CUTOFF = &CUTOFF;
%let wrds = wrds.wharton.upenn.edu 4016;
options comamid=TCP;
signon wrds username=_prompt_;
rsubmit;
/* Enter your WRDS institution name and your WRDS username */
options errors=2;
/* STEP 1: RETRIEVE DAILY TRADE AND QUOTE (DTAQ) FILES */
libname nbbo '/wrds/nyse/sasdata/taqms/nbbo';
libname cq '/wrds/nyse/sasdata/taqms/cq';
libname ct '/wrds/nyse/sasdata/taqms/ct';
libname mast '/wrds/nyse/sasdata/taqms/mast';
/* Create StockList each having 100 stocks */
proc sql noprint;
select ceil(count(SYMBOL_ROOT)/&CUTOFF) into :N_GROUP
from mast.mastm_&YYYYMMDD
where LISTED_MARKET in ('A' 'N' 'T' 'Q') /* AMEX, NYSE, NASDAQ */
and TAPE = 'A' /* Common stock */
; quit;
%do i=1 %to &N_GROUP;
%global STOCKLIST&i;
proc sql noprint;
select SYMBOL_ROOT into :STOCKLIST&i separated by '" "'
from mast.mastm_&YYYYMMDD
where LISTED_MARKET in ('A' 'N' 'T' 'Q') /* AMEX, NYSE, NASDAQ */
and TAPE = 'A' /* Common stock */
and monotonic() between &cutoff*(&i-1)+1 and &cutoff*&i
; quit;
/* Retrieve NBBO data */
data DailyNBBO;
/* Enter NBBO file names in YYYYMMDD format for the dates you want */
set nbbo.nbbom_&YYYYMMDD;
/* Enter company tickers you want */
where sym_root in ("&&STOCKLIST&i") and
/* Quotes are retrieved prior to market open time to ensure NBBO
Quotes are available for beginning of the day trades */
(("9:00:00.000000000"t) <= time_m <= ("9:30:00.000000000"t));
format date date9.;
format time_m part_time trf_time TIME20.9;
run;
/* Retrieve Quote data */
data DailyQuote;
/* Enter Quote file names in YYYYMMDD format for the same dates */
set cq.cqm_&YYYYMMDD;
/* Enter the same company tickers as above */
where sym_root in ("&&STOCKLIST&i") and
/* Quotes are retrieved prior to market open time to ensure NBBO
Quotes are available for beginning of the day trades*/
(("9:00:00.000000000"t) <= time_m <= ("9:30:00.000000000"t));
format date date9.;
format time_m part_time trf_time TIME20.9;
run;
/* Retrieve Trade data */
data DailyTrade;
/* Enter Trade file names in YYYYMMDD format for the same dates */
set ct.ctm_&YYYYMMDD;
/* Enter the same company tickers as above */
where sym_root in ("&&STOCKLIST&i") and
/* Retrieve trades during normal market hours */
(("9:30:00.000000000"t) <= time_m <= ("9:30:00.000000000"t));
type='T';
format date date9.;
format time_m part_time trf_time TIME20.9;
run;
/* Download to PC */
proc download data=DailyNBBO out=taq.DailyNBBO_&&YYYYMMDD&i; run;
proc download data=DailyQuote out=taq.DailyQuote_&&YYYYMMDD&i; run;
proc download data=DailyTrade out=taq.DailyTrade_&&YYYYMMDD&i; run;
%end;
%mend orderflow;
%orderflow(YYYYMMDD=20141224,CUTOFF=100);
任何评论表示赞赏。谢谢
此宏在本地机器上构造为 运行,因为它包含 SIGNON 和 RSUBMIT/ENDRSUBMIT 块。
但是您引用的是通过 SQL INTO 子句在远程计算机上创建的宏变量 N_GROUP
。我认为这是错误消息的原因。
在远程机器上将宏定义为 运行 或使用 %SYSRPUT
将宏变量值移回本地机器以便您可以使用它来控制 %DO
循环。