BookmarkSubscribeRSS Feed
siddharthpeesary
Calcite | Level 5

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.

11 REPLIES 11
SASKiwi
PROC Star

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.

siddharthpeesary
Calcite | Level 5
I like to run sas job on PC(windows)
pearsoninst
Pyrite | Level 9
There is a Schedule option in windows itself ..Pls Google it ..you will find the answer ...
siddharthpeesary
Calcite | Level 5
I will check it thanks
SASKiwi
PROC Star

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.

siddharthpeesary
Calcite | Level 5
Atually i want to write sas program required to create a file in database, then i want to use a time schedule from windows
SASKiwi
PROC Star

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
Calcite | Level 5
Kiwi I have to check the existence of file inside the sas job
LinusH
Tourmaline | Level 20

@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
SASKiwi
PROC Star

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

 

 

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