【发布时间】:2017-04-04 06:11:19
【问题描述】:
我将 SAS 用于大型数据集 (>20gb)。当我运行 DATA 步骤时,我收到“BY 变量未正确排序......”尽管我按相同的变量对数据集进行了排序。当我再次运行 PROC SORT 时,SAS 甚至说“输入数据集已排序,未完成排序” 我的代码是:
proc sort data=output.TAQ;
by market ric date miliseconds descending type order;
run;
options nomprint;
data markers (keep=market ric date miliseconds type order);
set output.TAQ;
by market ric date;
if first.date;
* ie do the following once per stock-day;
* Make 1-second markers;
/*Type="AMARK"; Order=0; * Set order to zero to ensure that markers get placed before trades and quotes that occur at the same milisecond;
do i=((9*60*60)+(30*60)) to (16*60*60); miliseconds=i*1000; output; end;*/
run;
错误信息是:
ERROR: BY variables are not properly sorted on data set OUTPUT.TAQ.
RIC=CXR.CCP Date=20160914 Time=13:47:18.125 Type=Quote Price=. Volume=. BidPrice=9.03 BidSize=400
AskPrice=9.04 AskSize=100 Qualifiers= order=116458952 Miliseconds=49638125 exchange=CCP market=1
FIRST.market=0 LAST.market=0 FIRST.RIC=0 LAST.RIC=0 FIRST.Date=0 LAST.Date=1 i=. _ERROR_=1
_N_=43297873
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 43297874 observations read from the data set OUTPUT.TAQ.
WARNING: The data set WORK.MARKERS may be incomplete. When this step was stopped there were
56770826 observations and 6 variables.
WARNING: Data set WORK.MARKERS was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 1:14.21
cpu time 26.71 seconds
【问题讨论】:
-
您在运行 proc sort 时是否在日志中收到错误消息?
-
肯定需要查看更多日志。观察计数非常奇怪 - 你有'if first.date',所以标记应该是 output.taq 的一个子集,但是在处理停止的时候,已经读取了 ~43.3m obs in从 output.taq 和 ~56.8m 已写入 out 到 work.markers...
-
@keydemographic 在 do-loop 中有一个输出语句,所以 obs 计数可以做各种各样的事情。
-
尝试将 FORCE 选项添加到 PROC SORT。可能只有 SAS 认为它已经排序。显然,在某些情况下,数据集的 SOLTEDBY 属性可能是错误的。
-
跳转到观察 #43297873 并从那里检查 +/- 5 个观察结果,以了解为什么它会说它没有按正确的顺序排序。
data check; set output.taq (firstobs=43297868 obs=43297878); run;
标签: sas