Hi all,
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)
2)%macro importdata(infile=,outfile=,type=,filter=);
proc import
datafile=&infile
dbms=&type
out=&outfile
replace;
&filter
run;
%mend importdata;
%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)
set DDA_BASED_S9_20151030;
run;
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.
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.
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.
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.
@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.
In that case check out the FILEEXIST function as it will do what you require:
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.