Hello guys,
I know we can calculate the dataset size using PROC SQL and some other way ,but is there any way to calculate a file size for physical file which is not imported in to the SAS system? Any predefined function for that to calculate the the file size for the given path??
note: I am using SAS EG 7.1
Please suggest me some ideas to achieve that 🙂
If its a SAS dataset, then you have the file size in sashelp.vtable. If its not, then you would need to rely on operating system functions to return that information. For instance, the x command on Windows can execute a dir command which can list a folders into a dataset, something like:
filename tmp pipe 'dir "c:\test\*.*"'; data want; length buff $200; infile tmp dlm="¬"; input buff $; run;
You can parse out information from that. Unix has its own commands.
Can anyone explain this code in detail manner?
Please avoid posting new questions in very old answered questions. Open a new thread if you have a new question.
In terms of my code, the pipe is a means of sending output from a command sent to the operating system (in this case a dir command), back to a dataset. So the filename sets this up, the datastep and infile actually run the command in your OS, and then the output is captured and read back in via the input.
Do you mean this:
Doesn't seem to work on our SAS, is it OS specific? Only other thing I could find was this:
https://support.sas.com/documentation/onlinedoc/sasc/doc700/html/lr1/z2055006.htm
Would be interested in seeing some doc on it.
Thanks for your help, Finally here its working code. But can you tell why its not writing the File_size value if we don't use %sysfunc??
%macro FileSize;
%let filrf=myfile;
%let rc=%sysfunc(filename(filrf,
'<FilePath>'));
%let fid=%sysfunc(fopen(&filrf));
%let Bytes=%sysfunc(finfo(&fid,File Size (bytes)));
%put &Bytes;
%mend;
%FileSize;
data A;
*File_Size=SYMGET('Bytes');
File_Size=%sysfunc(finfo(&fid,File Size (bytes)));
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.