我可以导航到文件资源管理器中的库路径,搜索我的dataset.sas7bdat文件并查看它的大小。
但那是不切实际的。我甚至不知道工作库在哪里,即使我知道了,它也在远程服务器上,这使得访问变得很复杂。
是否可以在日志或报表中打印数据集的大小/重量?
使用SAS EG 7.1和SAS 9.3
动机:我想这么做,因为我会尽量减少一个数据集的大小,我想知道我得到了多少。
发布于 2016-11-24 07:10:20
只要库使用基本引擎,就可以使用pathname()
函数查找它。之后,您可以使用sashelp视图来获取文件大小。您也可以使用os命令,但为此需要启用x命令。
以下说明:
%let libds=WORK.SAMPLE;
/* create demo data */
data &libds;
retain string 'blaaaaaaaah';
do x=1 to 10000;
output;
end;
run;
/* extract library and datasaet from libds variable */
%let lib=%scan(&libds,1,.);
%let ds =%scan(&libds,2,.);
/* set up filename to point directly at the dataset */
/* note - if you have indexes you also need to do */
/* this for the .sas7bndx extension */
filename fref "%sysfunc(pathname(&lib))/&ds..sas7bdat";
/* query dictionary view for file attributes */
data _null_;
set sashelp.vextfl(where=(fileref='FREF'));
filesize=filesize/(1024**2); /* size in MB */
putlog filesize= 'MB';
run;
/* clear libref */
filename fref clear;
https://stackoverflow.com/questions/40787564
复制相似问题