DATA Step, Macro, Functions and more

Automatically execute sas code

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

Automatically execute sas code

I'm now using SAS9.2, and I want to get my sas code run automatically to do some rountine work, is there any possible way? Thanks!


Accepted Solutions
Solution
‎02-02-2016 08:35 PM
Super User
Posts: 7,863

Re: Automatically execute sas code

[ Edited ]
Posted in reply to Wang_Yajun

The handling of the Windows Task Planner is described here:

http://www.digitalcitizen.life/how-create-task-basic-task-wizard

 

I would advise to create a batch file first that runs SAS with your program.

It should contain a line with something like this:

"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -sysin insert_program_here.sas -log where_you_want_a_log.log

 

Test this batch file from the cmd window first to see if it works, then use the Task Planner to create a scheduled event that runs the batch file.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Posts: 7,863

Re: Automatically execute sas code

[ Edited ]
Posted in reply to Wang_Yajun

Mostly depends on your setup. If you have SAS on a server, that server will provide a scheduling tool.

What you need is a script (batch, whatever your system wants) that runs SAS in batch mode with the supplied program.

 

Enterprise Guide already provides a method to create a job for a project so that the Windows scheduler can run it.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 29

Re: Automatically execute sas code

Posted in reply to KurtBremser

Hi,KurtBremser

Thanks for your reply. I don't have SAS EG on my personal PC. I have SAS 9.2 BASE installed in my PC, and my system is WIN7. I wonder if I can use base SAS code to get the SAS file run automatically . If not, could you give a sample script that can get the job done? Thanks a lot.

Solution
‎02-02-2016 08:35 PM
Super User
Posts: 7,863

Re: Automatically execute sas code

[ Edited ]
Posted in reply to Wang_Yajun

The handling of the Windows Task Planner is described here:

http://www.digitalcitizen.life/how-create-task-basic-task-wizard

 

I would advise to create a batch file first that runs SAS with your program.

It should contain a line with something like this:

"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -sysin insert_program_here.sas -log where_you_want_a_log.log

 

Test this batch file from the cmd window first to see if it works, then use the Task Planner to create a scheduled event that runs the batch file.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 7,863

Re: Automatically execute sas code

Posted in reply to Wang_Yajun

BTW, you should take a look at your SAS install media. EG is usually included with Base SAS and works with a locally installed SAS without need for additional server processes (Metadata, Spawner).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 5,441

Re: Automatically execute sas code

Posted in reply to Wang_Yajun

This is a guide for SAS 8/Win2K.

I think it still applies, even if some windows/search paths may be different from your setup.

 

http://support.sas.com/techsup/technote/ts648.pdf

 

Hope it isn't important stuff it should do, doesn't sound too reliable to execute batch jobs on a client PC.

Data never sleeps
Contributor
Posts: 29

Re: Automatically execute sas code

Hi, LinusH

 

Thanks for your reply, I help me a lot. 

Super User
Posts: 7,863

Re: Automatically execute sas code

Linus,

 

since his "client PC" also holds the core SAS software, I guess it is of a workstation type and is supposed to run round the clock. I also guess that scheduling in this context isn't so much a production thing and time-critical, but more of a personal helper.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 327 views
  • 4 likes
  • 3 in conversation