开发者

Getting file size of a random file in SAS (Windows)

开发者 https://www.devze.com 2023-01-24 04:16 出处:网络
I know that the finfo function in SAS returns filesize as one of the info fields in Unix. Is there an equivalent in Windows?

I know that the finfo function in SAS returns filesize as one of the info fields in Unix. Is there an equivalent in Windows?

I need to be able to get the total disk space used in a particular开发者_Go百科 folder from within SAS/AF code. Any suggestions would be welcome.

Thanks,

-- A


i've previously posted a sas macro to read windows directory listing here.


If you have SAS version 9.2 or later then this link will work regardless of OS:

http://support.sas.com/kb/38/267.html

Here is a paraphrased version of the link answering your question exactly:

%let filename = d:\sasdev\autoexec.sas;
data info; 
  length filesize $60; 
  drop rc fid close; 
  rc=filename("myfile","&filename"); 
  fid=fopen("myfile"); 
  filesize=finfo(fid,"File Size (bytes)"); 
  close=fclose(fid); 
  put filesize=;
run; 

Cheers Rob

PS - Have you checked out www.runsubmit.com? It's just like StackOverflow but for SAS related questions only.


I'm going to do something crufty and write a utility function that does the following:

  • If the file is a SAS dataset, then use standard SAS functions to get the filesize (some lrecl and nobs math)
  • Otherwise, if it is UNIX or SAS 9.2, use finfo
  • Otherwise, use a modified version of the macro written by @rkoopmann

Note that this is ok for me only because my requirements are to be able to get the size of a particular file.

0

精彩评论

暂无评论...
验证码 换一张
取 消