Below is the code which is used to pull the file attributes to the log.
Reference code: http://support.sas.com/kb/40/934.html
%macro FileAttribs(filename);
%global rc fid fidc;
%global Bytes CreateDT ModifyDT;
%let rc=%sysfunc(filename(onefile,&filename));
%let fid=%sysfunc(fopen(&onefile));
%let Bytes=%sysfunc(finfo(&fid,File Size (bytes)));
%let CreateDT=%qsysfunc(finfo(&fid,Create Time));
%let ModifyDT=%qsysfunc(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;
data DSN ;
length CreateDT_ ModifyDT_ $200. ;
/*Path of the file along with the file extension*/
%FileAttribs ( C:\Derived\GRSL.log ) ;
/*Creation date of the file*/
CreateDT_ = "&CreateDT" ;
/*Modification date of the file*/
ModifyDT_ = "&ModifyDT" ;
run;
I am copying the values in the macro variables into SAS variables. The macro variables hold the 19 August 2016 09:55:09 and does not fall into the acceptable date and time formats of SAS9.2. I want to convert the CreateDT_ and ModifyDT_ to numeric. I tried doing it by manually convert search the string with SUBSTR function. Is there a way to handle it dynamically without manually searching the string for date month, year and time. Is there a way to control the file attribute formats, for example the above program returns 01 March 2017 05:22:30 o'clock during few runs and few other times the date01 MAR 2017 05:22:30. The date format keeps changing.