- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think it's LAST MODIFIED for FINFO?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry I have updated this, I left this in by mistake, when I use Last my result is still null :S
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, quick question how do I close the file? I tired
fid = fclose ("onefile");
But it doesnt work
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
To close the file and reset the file reference, do
rc = fclose(fid);
rc = filename("onefile");
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Or Dictionary table . filename xx '/folders/myfolders/xx.rtf'; proc sql; select * from dictionary.EXTFILES where fileref='XX'; quit;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Or querying Dictionary table . filename xx '/folders/myfolders/xx.rtf'; proc sql; select * from dictionary.EXTFILES where fileref='XX'; quit;