BookmarkSubscribeRSS Feed
Scottcom4
Calcite | Level 5
Good Afternoon All,

I have a file which sits in a folder on our server which is read only. This file is overidden monthly with new data from an external source. The date which this update is made is not consistant and therefore a batch job which runs on any specific date is impossible (well pointless).

What I originally wanted to do (without knowing the directory was read only) was to move the file to a new location on the day which it was updated, delete the initial file and run the rest of my code on the newly transfered data. The code for this was simple and worked like a charm. However, I discovered that the directory was read only and therefore my daily batch wants to pick it up everyday (as the file always exists).

I wondered if anyone knew a way of SAS identifying when a file had been modified, via the modified date.

Any help would be fantastic.

Regards,
Scott
4 REPLIES 4
LinusH
Tourmaline | Level 20
This should've been a perfect task for the FINFO function. However, on 9.1.3/Solaris it has support only for File name, Owner name, Group name, Access Permission and File Size. If you have access to 9.2, try to run this code end see if something else pops up:

data info;
length infoname infoval $60;
*drop rc fid infonum i close;
rc=filename('abc','~/inf.txt');
fid=fopen('abc');
infonum=foptnum(fid);
do i=1 to infonum;
infoname=foptname(fid,i);
infoval=finfo(fid,infoname);
output;
end;
close=fclose(fid);
run;

Otherwise, I guess you have to use os commands to retrieve the information you want. That can be done quite neatly by using the PIPE filename option.

/Linus
Data never sleeps
Scottcom4
Calcite | Level 5
Thanks Linus.

Unfortunately I am presently stuck using 9.1.3.

I have attempted to use the following OS commands with no success:

Systask Command "Copy &ServerX.\pordata.tpt /y
&serverl.\Pordata&eom..tpt" Taskname = T01;
Waitfor T01;

Systask Command "Del &ServerX.\pordata.tpt" Taskname = T02;
Waitfor T02;

AND

Systask Command "Move &ServerX.\pordata.tpt /y
&serverl.\Pordata&eom..tpt" Taskname = T01;
Waitfor T01;

Are there any other commands that I could use to get past my permissions issue?

Thank you.
Scott
Doc_Duke
Rhodochrosite | Level 12
This is a bit round-about, but you could run the DOS DIR command via the SAS X statement and pipe the results to a file that you can then read that to get the date on the file.

something like
x 'die&ServerX.\pordata.tpt > myfile.txt';

and then parse myfile.txt. You can probably simplify this by using the FILENAME statement with unnamed PIPEs.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Along the same idea from Doc@Duke, the FILENAME supports the "pipe" engine to read/process a directory list. Check the SAS support website for additional references - here is one SUGI/SGF paper on the topic.

Scott Barry
SBBWorks, Inc.

http://www2.sas.com/proceedings/sugi25/25/cc/25p103.pdf

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1006 views
  • 0 likes
  • 4 in conversation