Getting file size of arbitrary file in SAS (Windows)

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

I need to be able to get the total disk space used in a specific folder from SAS / AF code. Any suggestions are welcome.

Thanks,

- A

+4
source share
3 answers

I previously posted the sas macro to read the list of Windows directories here .

+2
source

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

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

Here is a paraphrased version of the link that answers 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 www.runsubmit.com ? This is like StackOverflow, but only for SAS related issues.

+2
source

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

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

Please note that this is normal for me only because my requirements should be able to get the size of a specific file.

0
source

All Articles