I was trying to import excel to sas grid and add the last modified timestamp for the file into the table.
Referred to the sas support I was able to retrieve the last modified time. But I am having trouble with add the time as a new column into the table.
I got this error:
SYMBOLGEN: Macro Variable LASTMODIFIED resolves to 09May2023:16:33:19
NOTE: LINE generated by the macro variable "LASTMODIFIED"
282 09May2023:16:33:19
----------
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!....
ERROR 76-322: Syntax error, statement will be ignored.
Here is the code I tried:
%macro FileAttribs(filename);
%local rc fid fidc ModifyDT;
%let rc=%sysfunc(filename(onefile,&filename));
%let fid=%sysfunc(fopen(&onefile));
%if &fid ne 0 %then %do;
%let ModifyDT=%sysfunc(finfo(&fid,Last Modified));
%let fidc=%sysfunc(fclose(&fid));
%let rc=%sysfunc(filename(onefile));
%put NOTE- Last modified &modifydt;
proc sql;
create table work.final as
select *, &modifydt. as lastmodified
from work.tb; --the imported table from excel
%end;
%else %put &filename could not be open.;
%mend FileAttribs;
Also tried to cast the variable to different datatype but also failed.