Hi I have automated a process, and I was interested to know whether it is possible to get the last modified date of the file(txt,xls..etc) which is imported..
My problem or rather intention is to validate the file which is getting imported. I mean, I am importing a file from the Server(remote), which is supposed to be replaced or modified everyday by my user. At times it happens that user may not replace the file at the specified time(usually 1 hr prior to sceduled stream), if that is the case I would like to check that the file which is getting imported is a modified file or not by looking at the modified date.
Alternatives like telling the business user to give a different name with date..etc are not feasible due to some internal issues.
Yes, investigate using the SAS FINFO CALL function. The SAS support website has SAS-hosted documentation and supplemental technical reference material showing examples - as well, you may want to search the archives.
Suggested Google advanced search argument, this topic / post:
You'll find this example code which is all you need to get started:
length infoname infoval $60;
drop rc fid infonum i close;
do i=1 to infonum;
Be aware that also other processes like disk backup/restore or a compress could change a create or modified date.
An alternative to FINFO would be to directly execute a OS command and then capture the result (i.e. using "filename pipe ...").
If not already on SAS 9.2 this will encourage your upgrade somewhat. Before 9.2 the file date is not available through FINFO. Then it was a lot more op.sys- and release-specific to extract the dates.
I'm trying to encourage SAS to provide these pieces of external file information in a simple way through infile options or PROC import. Already some of this is reported to the SAS log or a macro variable like &dbsysmsg and variants. More could be done for the external files we read with SAS.
add your voice through the sasware ballot
I think FILENAME + PIPE is just more simple.
It can easily get the modifed date of file.
filename date pipe 'dir c:\temp\ /a';
data temp(keep=date time file_name);
infile date length=len;
input whole $varying200. len;
if findc(file_name,'.') and file_name not in ('.' '..') then output;