27%macro mf_getfilesize(fpath=,libds=0,format=NO
30 %local rc fid fref bytes dsid lib vnum;
32 %
if &libds ne 0 %then %
do;
33 %let libds=%upcase(&libds);
34 %
if %index(&libds,.)=0 %then %let lib=WORK;
35 %
else %let lib=%scan(&libds,1,.);
36 %let dsid=%sysfunc(open(
37 sashelp.vtable(where=(libname=
"&lib" and memname=
"%scan(&libds,-1,.)")
38 keep=libname memname filesize
41 %
if (&dsid ^= 0) %then %
do;
42 %let vnum=%sysfunc(varnum(&dsid,FILESIZE));
43 %let rc=%sysfunc(fetch(&dsid));
44 %let bytes=%sysfunc(getvarn(&dsid,&vnum));
45 %let rc= %sysfunc(close(&dsid));
47 %
else %put &sysmacroname: &libds could not be opened! %sysfunc(sysmsg());
50 %let rc=%sysfunc(filename(fref,&fpath));
51 %let fid=%sysfunc(fopen(&fref));
52 %let bytes=%sysfunc(finfo(&fid,File Size (bytes)));
53 %let rc=%sysfunc(fclose(&fid));
54 %let rc=%sysfunc(filename(fref));
57 %
if &format=NO %then %
do;
61 %sysfunc(INPUTN(&bytes, best.),sizekmg.)