All,
Below code give list of files and their sizes but it will not give subfolder size/subfolder file sizes.
is there a way that can read subfolder/file sizes .
we disabled XCMD so need to use this SAS code.
So I am looking for total folder size, subfolder size ,all file lists and sizes.
%macro getfilesizes(directory, extension, dataset) ;
data &dataset. ;
length FILE $256 DTE 8 SIZE 8 DIRECTORY $256 FILRF FILRFB $8 ;
format DTE datetime.;
keep FILE DTE SIZE DIRECTORY ;
DIRECTORY= "&directory";
RC1 = filename(FILRF,DIRECTORY);
DID = dopen(FILRF);
MEMCOUNT = dnum(DID);
do I=1 to MEMCOUNT;
FILE = dread(DID,I);
if "&extension" = scan(FILE,-1,'.') or "&extension" = "all" then do;
RC2 =filename(FILRFB, catx('/', DIRECTORY, FILE) );
FID =fopen(FILRFB);
if FID then do;
DTE =input(finfo(FID,'Last Modified'),anydtdtm.);
SIZE=input(finfo(FID,'File Size (bytes)'),32.);
end;
else call missing(DTE,SIZE);
output;
RC3 =fclose(FID);
RC4 =filename(FILRFB);
end;
end;
RC5=dclose(DID); RC6=filename(FILRF);
run;
%mend getfilesizes;
libname test "/test";
%getfilesizes(directory=%sysfunc(pathname(test)), extension=all, dataset=folder_size)
we can calculate file size by using picture format
https://communities.sas.com/t5/SAS-Programming/Proc-report-file-size-in-GBs/td-p/696146
thanks to @Kurt_Bremser
Just had a similar question today:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.