11-25-2015 12:41 PM
I have a file named DDA_BASED_S9_20151030
I have a folder where every month end above file will be dumped(the file name will be same except only month and year (i.e 201510)
so My job is to running every month
1)libname mydblib odbc datasrc=XXXXX user=XXXXXXX password=XXXXXXX; (->creates connection)
%importdata(infile='PATH\DDA_BASED_S9_20151030.csv',outfile=DDA_BASED_S9_20151030,type=csv,filter=); (->imports file)
3)data mydblib.DDA_BASED_S9_20151030;(->saves data into the database)
Program for Automation work:
But Now I like to make it automated,
1)I like to write a program so every month where it has to check for paricular FILE in an particular FOLDER automatically without opening sas program, like using scheduler and send the file to database
can anyone tell me the process(code) for it ,it will be very helpful thanks. SO that i can use for other programs as a reference
Thanks In Advance.
Please let me know if there are any misconception.
11-25-2015 01:51 PM
There are many schedulers available that can check for the existence of a file to trigger a batch job. Where are you going to run your SAS job? On a PC or on a SAS server? If it is a SAS server, which is what I would recommend, I suggest you talk to your SAS admin folks to see how they schedule jobs.
Running scheduled tasks on PCs is not very reliable as they need to be switched on, have a working network connection, and have a valid username for running the scheduled task under. Servers are much better for this.
11-25-2015 02:16 PM
The Windows task scheduler can be used with SAS but it can only do time scheduling, not file event scheduling. You would need to either use a third-party scheduler of your choice that can do file events or add a file exist check to your SAS job.
11-25-2015 02:24 PM
If you don't want to check for the existence of your input file in the scheduler then the Windows scheduler in your Control Panel can just do the time scheduling.
11-25-2015 03:42 PM
@siddharthpeesary first you say you want a program to check the file without opening SAS. Then you say that the SAS program need to do this. Contradictory.
If you want a scheduler/OS script to this, you need to search on such forum instead, not SAS communities.
If you need a SAS program to do the check, there are lots of external file functions in SAS that are useful in situations like this.
11-25-2015 03:46 PM
In that case check out the FILEEXIST function as it will do what you require: