How can SAS be used to determine the size of a dir

2019-07-21 02:00发布

问题:

Am looking for some (efficient) code to determine the size of a directory / folder in Windows XP using SAS 9.1.3.

回答1:

If you are not constrained by the SAS NOXCMD option (such as SAS Enterprise Guide hitting a SASApp - Workspace Server in its default configuration where the administrator has not opened it up) then I would suggest downloading and using the Microsoft Sysinternals Disk Usage (DU) tool via a SAS data null step using a pipe filename. Here is some sample SAS code:

filename du pipe "du -q c:\SAS\EBIEDIEG\Lev1\SASApp";
data work.diskusage;
infile du;
input @;
put _infile_;
if ( _infile_ =: 'Size:' ) then do;
    sizeInBytes = input(scan(_infile_,2,' '), comma32.);
    output;
end;
input;
run;

Microsoft Sysinternals Disk Usage (DU) is similar to the familiar UNIX du command. You can download Sysinternals DU and review the documentation at http://technet.microsoft.com/en-au/sysinternals/bb896651 It has a -l parameter so you can specify how deep it should go.

If you are constrained by the NOXCMD option then you could use a series of loops using the SAS DOPEN/DREAD/FILENAME/FOPEN/FINFO/FCLOSE/DCLOSE functions to manually walk the directory tree and add up the file sizes. It will involve much more code but should run in a NOXCMD environment. If you want to use this method then a good starting point will be the SAS documentation for DOPEN at http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000209538.htm where you will also be able to find the documentation and examples for the other functions.



标签: windows sas