BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
craig159753
Quartz | Level 8

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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

View solution in original post

8 REPLIES 8
craig159753
Quartz | Level 8

Sorry I have updated this, I left this in by mistake, when I use Last my result is still null :S

Kurt_Bremser
Super User

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
craig159753
Quartz | Level 8

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.);

craig159753
Quartz | Level 8

Hi, quick question how do I close the file? I tired 

 

fid = fclose ("onefile");

 

But it doesnt work

Ksharp
Super User
Or Dictionary table .




filename xx '/folders/myfolders/xx.rtf';
proc sql;
select * 
 from dictionary.EXTFILES
  where fileref='XX';
quit;




Ksharp
Super User
Or querying Dictionary table .

filename xx '/folders/myfolders/xx.rtf';
proc sql;
select * 
 from dictionary.EXTFILES
  where fileref='XX';
quit;




sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 7014 views
  • 4 likes
  • 4 in conversation