Hi, I am trying to get the last date modified for an EXCEL sheet, however the returned value is blank not sure why. I am running the following bit of code on SAS 9.4.
%let specname = XXX99999 Mapping v0.1;
%let rc = %sysfunc(filename(onefile, %str(.\Docs\&specname..xls))));
%let fid = %sysfunc(fopen(&onefile.));
%let modifydt = %sysfunc(finfo(&fid, Last Modified));
%let fidc = %sysfunc(fclose(&fid.));
%let rc = %sysfunc(filename(onefile));
The log then shows this,
SYMBOLGEN: Macro variable MODIFYDT resolves to
Any ideas why this may happen?
I find it MUCH more convenient to avoid the %sysfunc and %str hailstorm by using a data _null_ step:
(This is UNIX, of course)
data _null_;
rc = filename("onefile","$HOME/test.txt");
fid = fopen("onefile");
modifydt = finfo(fid,"Last Modified");
call symput('modifydt',modifydt);
run;
%put &modifydt.;
The correct parameter for the finfo function is "Last Modified", as per FINFO Function: Windows
Result here:
16 data _null_; 17 rc = filename("onefile","$HOME/test.txt"); 18 fid = fopen("onefile"); 19 modifydt = finfo(fid,"Last Modified"); 20 call symput('modifydt',modifydt); 21 run; NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 22 23 %put &modifydt.; Tue Jun 28 08:53:29 2016
I think it's LAST MODIFIED for FINFO?
Sorry I have updated this, I left this in by mistake, when I use Last my result is still null :S
I find it MUCH more convenient to avoid the %sysfunc and %str hailstorm by using a data _null_ step:
(This is UNIX, of course)
data _null_;
rc = filename("onefile","$HOME/test.txt");
fid = fopen("onefile");
modifydt = finfo(fid,"Last Modified");
call symput('modifydt',modifydt);
run;
%put &modifydt.;
The correct parameter for the finfo function is "Last Modified", as per FINFO Function: Windows
Result here:
16 data _null_; 17 rc = filename("onefile","$HOME/test.txt"); 18 fid = fopen("onefile"); 19 modifydt = finfo(fid,"Last Modified"); 20 call symput('modifydt',modifydt); 21 run; NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 22 23 %put &modifydt.; Tue Jun 28 08:53:29 2016
This worked, I added a bit of code to change the format though
modifydt = finfo(fid,"Last Modified");
lastmodified = input((trim(scan(modifydt, 1, " ") || substrn(scan(modifydt, 2, " "), 1, 3) || scan(modifydt, 3, " ")) || ":" || scan(modifydt, 4, " ")), datetime20.);
Hi, quick question how do I close the file? I tired
fid = fclose ("onefile");
But it doesnt work
To close the file and reset the file reference, do
rc = fclose(fid);
rc = filename("onefile");
Or Dictionary table . filename xx '/folders/myfolders/xx.rtf'; proc sql; select * from dictionary.EXTFILES where fileref='XX'; quit;
Or querying Dictionary table . filename xx '/folders/myfolders/xx.rtf'; proc sql; select * from dictionary.EXTFILES where fileref='XX'; quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.