在 SAS 中删除表 [英] Dropping a table in SAS

查看:209
本文介绍了在 SAS 中删除表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SAS 中删除表的最有效方法是什么?

What is the most efficient way to drop a table in SAS?

我有一个程序,循环删除大量表,想知道PROC SQL之间是否存在性能差异;和过程数据集;一次删除一个表..

I have a program that loops and drops a large number of tables, and would like to know if there is a performance difference between PROC SQL; and PROC DATASETS; for dropping a single table at a time..

或者如果有另一种方式也许???

Or if there is another way perhaps???

推荐答案

如果外包给操作系统是合理的,那可能是最快的.否则,我的不科学观察似乎表明 proc sql 中的 drop table 是最快的.这让我感到惊讶,因为我期望 proc datasets 是最快的.

If it is reasonable to outsource to the OS, that might be fastest. Otherwise, my unscientific observations seem to suggest that drop table in proc sql is fastest. This surprised me as I expected proc datasets to be fastest.

在下面的代码中,我创建了 4000 个虚拟数据集,然后尝试使用不同的方法将它们全部删除.第一个是使用 sql,在我的系统上删除文件大约需要 11 秒.

In the code below, I create 4000 dummy data sets then try deleting them all with different methods. The first is with sql and on my system took about 11 seconds to delete the files.

接下来的两个都使用proc数据集.第一个为每个数据集创建一个删除语句,然后删除.第二个只是发出一个全面的 kill 命令来删除工作目录中的所有内容.(我原以为这种技术是最快的).两个 proc datasets 例程都报告删除所有 4000 个文件大约需要 20 秒.

The next two both use proc datasets. The first creates a delete statement for each data set and then deletes. The second just issues a blanket kill command to delete everything in the work directory. (I had expected this technique to be the fastest). Both proc datasets routines reported about 20 seconds to delete all 4000 files.

%macro create;
proc printto log='null';run;
%do i=1 %to 4000;
data temp&i;
x=1;
y="dummy";
output;run;
%end;
proc printto;run;
%mend;

%macro delsql;
proc sql;
%do i=1 %to 4000;
drop table temp&i;
%end;
quit;
%mend;

%macro deldata1;
proc datasets library=work nolist;
   %do i=1 %to 4000;
   delete temp&i.;
   %end;
run;quit;
%mend;

%macro deldata2;
proc datasets library=work kill;
run;quit;
%mend;

option fullstimer;
%create;
%delsql;

%create;
%deldata1;

%create;
%deldata2;

这篇关于在 SAS 中删除表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆