Trying to get file attributes (file size, date creation time and last modified time) in SAS

I use the following macro to get Linux file attributes using SAS. I get the values ​​for the size and last modified time, but I don't get any values ​​for the "Create Date Time".

%macro FileAttribs(filename);
  %local rc fid fidc;
  %local Bytes CreateDT ModifyDT;
   %let rc=%sysfunc(filename(onefile,&filename));
   %let fid=%sysfunc(fopen(&onefile));
   %let Bytes=%sysfunc(finfo(&fid,File Size (bytes)));
   %let CreateDT=%sysfunc(finfo(&fid,Create Time));
   %let ModifyDT=%sysfunc(finfo(&fid,Last Modified));
   %let fidc=%sysfunc(fclose(&fid));
   %let rc=%sysfunc(filename(onefile));
    %put NOTE: File size of &filename is &Bytes bytes;
    %put NOTE: Created &CreateDT;
    %put NOTE: Last modified &ModifyDT;
%mend FileAttribs;

%FileAttribs(/path/test.csv);

I could not understand what I was missing. Are there any other file attributes that we can get besides size, creation, and changing dates?

Thanks, Sumpaty.

+4
source share
2 answers

Linux- ( , ): https://unix.stackexchange.com/questions/91197/how-to-find-creation-date-of-file.

, FINFO(), FOPTNUM(), , . :

%macro GetAllAttributes(file);

  %local rc fref fid i AttributeName AttributeValue;

  %let rc=%sysfunc(filename(fref,&file));
  %let fid=%sysfunc(fopen(&fref));

  %do i=1 %to %sysfunc(foptnum(&fid));
    %let AttributeName=%sysfunc(foptname(&fid,&i));
    %let AttributeValue=%sysfunc(finfo(&fid,&AttributeName));
    %put &AttributeName : &AttributeValue;
  %end;

  %let fid=%sysfunc(fclose(&fid));
  %let rc=%sysfunc(filename(fref));

%mend GetAllAttributes;

Windows (SAS 9.3) :

78   %GetAllAttributes(d:\junk\somefile.txt)
Filename : d:\junk\somefile.txt
RECFM : V
LRECL : 256
File Size (bytes) : 1011
Last Modified : 06Dec2013:14:14:54
Create Time : 06Dec2013:14:14:52

Linux (SAS 9.3) :

41         %GetAllAttributes(~/somefile.txt)    
Filename : /home/Quentin/somefile.txt
Owner Name : Quentin
Group Name : somegroup
Access Permission : rwx------
Last Modified : Fri Dec  6 14:14:54 2013
File Size (bytes) : 1011

, , SAS 9.3 Linux . , 9.4 SAS- , Windows. 9.3, : SAS Linux.

+2

, SAS FINFO Unix. , , , .

, Windows, , , Linux/Unix. Windows - , Unix/Linux, 9.3. ( 9.4, .)

0

Source: https://habr.com/ru/post/1620818/


All Articles