我遇到以下错误。
错误:在%EVAL函数或%IF条件中找到了一个字符操作数,其中需要一个数字操作数。条件是:& N_GROUP
错误:%DO I循环的%TO值无效。
错误:宏ORDERFLOW将停止执行。
当我在没有远程提交的情况下在本地测试时,它有效。但它在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);
任何评论都表示赞赏。感谢。
答案 0 :(得分:1)
此宏构造为在LOCAL机器上运行,因为它包含SIGNON和RSUBMIT / ENDRSUBMIT块。
但是您正在引用通过SQL INTO子句在远程计算机上创建的宏变量N_GROUP
。我认为这是错误消息的原因。
定义要在远程计算机上运行的宏,或使用%SYSRPUT
将宏变量值移回本地计算机,以便您可以使用它来控制%DO
循环。