Help using Base SAS procedures

Automatic scheduler for SAS job

Reply
Contributor
Posts: 38

Automatic scheduler for SAS job

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.

Super User
Posts: 3,250

Re: Automatic scheduler for SAS job

Posted in reply to siddharthpeesary

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.

Contributor
Posts: 38

Re: Automatic scheduler for SAS job

I like to run sas job on PC(windows)
Frequent Contributor
Posts: 108

Re: Automatic scheduler for SAS job

Posted in reply to siddharthpeesary
Frequent Contributor
Posts: 108

Re: Automatic scheduler for SAS job

Posted in reply to siddharthpeesary
There is a Schedule option in windows itself ..Pls Google it ..you will find the answer ...
Contributor
Posts: 38

Re: Automatic scheduler for SAS job

Posted in reply to pearsoninst
I will check it thanks
Super User
Posts: 3,250

Re: Automatic scheduler for SAS job

Posted in reply to siddharthpeesary

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.

Contributor
Posts: 38

Re: Automatic scheduler for SAS job

Atually i want to write sas program required to create a file in database, then i want to use a time schedule from windows
Super User
Posts: 3,250

Re: Automatic scheduler for SAS job

Posted in reply to siddharthpeesary

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.

Contributor
Posts: 38

Re: Automatic scheduler for SAS job

Kiwi I have to check the existence of file inside the sas job
Super User
Posts: 5,424

Re: Automatic scheduler for SAS job

Posted in reply to siddharthpeesary

@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.

Data never sleeps
Super User
Posts: 3,250

Re: Automatic scheduler for SAS job

Posted in reply to siddharthpeesary

In that case check out the FILEEXIST function as it will do what you require:

 

http://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#n06xm8hwk0t...

 

 

Ask a Question
Discussion stats
  • 11 replies
  • 478 views
  • 0 likes
  • 4 in conversation