Write and run SAS programs in your web browser

Automate SAS Script

Reply
Occasional Contributor
Posts: 7

Automate SAS Script

Hello everyone,

 

I'm currently trying to automate two SAS programs.

 

1. I want a SAS script to run at 3 seperate times 5 days a week. M-F at 12 pm, 4 pm and 7 pm EST. The only method I've gotten to work is that Windows will run SAS studios and open the SAS script for me, but it won't press 'Run'.

 

2. I want a SAS script to be triggered by a change in the source table that I'm using. A little context, the source table has entries put into it anytime an external script 'fails' and puts all the information about the job into a row based table. I want my SAS script to pull these entries as soon as the table has entries put into it.

 

Thanks for any tips

Valued Guide
Posts: 505

Re: Automate SAS Script

Not a complete answer., but it might help.

You may need to have your programs check the 'trigger' file. I like to use
a Perl script to do the checking and execute the SAS jobs.

/* T004680 SETTING UP CHRON JOBS ON UNIX AND WINDOWS

THIS IS A VERY OLD TIP CIRCA WIN 2000
=====================================

start>Control Panel\System and Security\Administrative Tools\scheduled tasks

put the following in run dialog box
C:\Program Files\SAS\SAS 9.1\sas.exe" -nosplash -sysin c:\sas\pgm.sas -log nul: -print nul:
put the following in start in box
c:\sas

You don't have to have a null log or null list.
I send an email with the log and list when the program fails

IN UNIX
=======

create a file called cronjob.txt with just the line below

0 2 * * 1-5 /groundtruth/programs/program.csh

Details
mm hh dd mon day
0   2  *  *  1-5 /groundtruth/programs/program.csh

run at 2am every monday-friday

here is what program.csh looks like(executes sas myprogram
#!/usr/bin/csh
cd /groundtruth/sas/programs
/groundtruth/local/bin/sas mysasprogram

You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow

crontab -e      Edit your crontab file, or create one if it doesn?t already exist.
crontab -l      Display your crontab file.
crontab -r      Remove your crontab file.
crontab -v      Display the last time you edited your crontab file.



Occasional Contributor
Posts: 7

Re: Automate SAS Script

"

THIS IS A VERY OLD TIP CIRCA WIN 2000
=====================================

start>Control Panel\System and Security\Administrative Tools\scheduled tasks

put the following in run dialog box
C:\Program Files\SAS\SAS 9.1\sas.exe" -nosplash -sysin c:\sas\pgm.sas -log nul: -print nul:
put the following in start in box
c:\sas

You don't have to have a null log or null list.
I send an email with the log and list when the program fails

"

 

So this bit I have used before but whenever I use it this way it literally just opens SAS for me and then opens 'pgm.sas' to work on but does nothing else. Doesn't run the job as I would obviously want it to do.

 

As for the UNIX solution I unfortunately don't have access to run shell scripts in the system I'm working on. 

Respected Advisor
Posts: 2,901

Re: Automate SAS Script

As far as I'm aware you can't currently schedule programs via SAS Studio. How are you using SAS Studio? With a remote SAS server, SAS UE or some other method? If you are using a remote server, that will usually have scheduling tools available to you.

Post a Question
Discussion Stats
  • 3 replies
  • 110 views
  • 0 likes
  • 3 in conversation