【发布时间】:2017-11-16 23:13:06
【问题描述】:
有SO question on split a large dataset into smaller one,但随着proc ds2 的出现,一定有办法使用线程来做到这一点?
我已经编写了以下数据步骤来将数据集拆分为&chunks. 块。我试图在proc ds 中写同样的内容,但它失败了。我对proc ds2 还很陌生,所以对于对数据步骤有很好理解的人来说一个简单的解释是理想的。
数据步码
%macro output_chunks(in, out, by, chunks);
data %do i = 1 %to &chunks.;
&out.&i.(compress=char drop = i)
%end;
;
set &in.;
by &by.;
retain i 0;
if first.&by. then do;
i = i + 1;
if i = &chunks.+1 then i = 1;
end;
%do i = 1 %to &chunks.;
if i = &i. then do;
output &out.&i.;
end;
%end;
run;
%mend;
proc ds2 代码
proc ds2;
thread split/overwrite=yes;
method run();
set in_data;
thisThread=_threadid_;
/* can make below into macro but I can't seem to get it to work */
if thisThread = 1 then do;
output ds1;
end;
else if thisThread = 2 then do;
output ds2;
end;
end;
method term();
put '**Thread' _threadid_ 'processed' count 'rows:';
end;
endthread;
run;
quit;
【问题讨论】:
-
澄清一下:您想在这里专门讨论sas-ds2 解决方案吗?或者您想找到比常规数据步骤更有效的通用解决方案吗? (例如,使用哈希表执行此操作的方法比我在该线程中建议的解决方案更有效。)
-
注意:我为该问题添加了哈希解决方案。
-
您是否安装了 SAS/CONNECT?这可能是另一种可能的方法。