Download the PDF version from here
ABSTRACT
Efficient use of the server’s time and managing your time in today’s environment, overloaded with data, demands implication of more and more completely automated processes running 24/7 on autopilot. For example, most of the customers chose to transfer their data using secure data transfer channels to protect it. That creates a huge load on the servers and consumes significant amount of programmer’s time. One of the solutions proposed here is to use Windows Task Scheduler and move the routine processes out of the regular work time. That will reduce the load of the server, during the normal work hours and allow the programmers to use their time in a more efficient way.
INTRODUCTION
Automating and moving the repetitive processes away from the regular work hours is a smart way to free yourself from the boring routines and concentrate on producing solutions for the task at hand. If you are dealing with multiple projects, requiring load of repetitive jobs like downloading data from the customer and uploading back reports on a regular basis, you definitely are looking for ways to automate those steps. In this article you’ll find how to use Task Scheduler on Windows server to trigger your SAS program(s). Hopefully, that example will help you or inspire you to do your research and find a proper solution for your specific situation.
PROBLEM
Repetitive processes are occupying significant amount of server’s and programmer’s time in today’s data overloaded world.
SOLUTION
Moving the routine processes away from the regular work time could be an important solution for you and your company. One way to complete that task on a Windows server is to schedule SAS jobs using Task Scheduler which comes as a standard application.
The following steps are showing how to set up your program to be triggered at a desired time using Task Scheduler on Windows Server 2008.
STEP-BY-STEP PROCESS
The plan of action:
1. Schedule a test run of the job during the first possible off-hours period, for ex: 3AM next day
2. As soon as the job scheduling is complete, force the Task Scheduler to trigger it immediately. Look for errors and bugs in the process and remove them.
3. Check the results of the overnight test run next morning.
Look for errors and remove them.
4. Schedule the job as you’d normally need it to be run.
Check the log and the quality of the program’s output for possible errors.
SAS software has endless number of procedures and tools which could be used to assure smooth and easy quality control steps and monitoring of the job done, so that we can assure the final product has been delivered. In order to keep the focus on the topic, I am not going to distract you with those additional solutions in this paper. However feel free to do your research and incorporate the results into your work.
Here are the detailed steps as done on Windows server 2008:
Open Task Scheduler by clicking Start-Administrative Tools-Task Scheduler
(click on the image to enlarge it)

Click on Create Basic Task on the top right corner

Enter the Name of the job and a short description and click Next

As you are going to test the job first, Select One time option on that window and click Next

Select the first possible day and time out of the regular work hours. For example 3AM next day. We are going to test the program immediately after the scheduling is completed, regardless of what the trigger time is

Select Start a program, however look at the other options here. They can be helpful for other projects

On the next window, shown below, Task scheduler has to be instructed on which application to open and the specific program within it:
Here is the exact command line:
"C:\Program Files\SAS\SASFoundation\9.2\sas.exe" -sysin "D:\Projects\MySASprogram.sas" -log "D:\Projects\mylog.log"
There are 3 parts in this command line:
a. The first one instructs the Task scheduler to open SAS
b. The –sysin argument specifies which SAS program to be triggered
c. The –log argument instructs where the log to be saved
There are at least two reason to include –log argument in the command line
You need to check the log for proper execution of the program
You may not have administrative access to the Programs folder on the server and that will trigger an error preventing the program from execution. Why? An attempt will be made to save the log in the Programs folder, by default, if not other settings have been done beforehand.
The double quotes make sure that if any blanks are included in the path, they will not confuse the command execution.
There should be a blank space before and after each argument.
Here is where the command line above has to be pasted.
Then click Next.
Task scheduler will ask you to confirm the program and the arguments, Click Yes.
Check the box next to Open the Properties dialog for this task and click Finish
On the Property dialog select the radio button next to Run whether user is logged on or not. If the task is going to be scheduled later on for a midnight run you may not be logged on at that particular time
Now is the time to test if the program will be triggered correctly. If you do not see the program listed under the Names, click on Task Scheduler Library on the top left corner.
Point the mouse over the program’s name as it is shown on the screen shot below and Right click. Left click on Run. The program should be triggered and the results generated properly. Check the log for errors.
You may encounter unexpected system errors and need to consult your IT department on solving those issues.
Once the first test is done, you have to wait for the results of the overnight test. On the next morning, check if the program has been triggered and all of the expected outcomes have been properly generated. Remove the errors and reschedule the next testing time for the next off-hours period.
If everything is OK, then reschedule the job for the regular times when you’d like the process to be executed. Below are the details of how this can be done.
Point the mouse over the program name, Right click and select Properties from the drop-down menu.
Click on Triggers tab
Click on Edit button below
Start editing from the top field. I use On a schedule option, however see what other choices you have here and make yours
The Settings field has four options and each one has additional sub-options as shown below. One time option is the simplest: set up the date and the time you want the program to run
The Daily option gives you the opportunity to submit the program every day, or every other day, or … you get the idea
The Weekly option gives you the choice to trigger the program based on a weekly intervals and the weekdays within those intervals
Monthly option is giving you the flexibility to select any months, days or weekdays periods
Pay attention to the Advanced settings field, where you can stop the task from running in excessively long time, set up expiration date and most importantly deactivate or activate the scheduled job
Once you are done, click on OK button, again
Now the scheduler will ask you for the password in order to confirm the authorship and save the changes
Entering the above password raises the question what will happen to the scheduled job when you are prompted by the system to change it on a certain time intervals. There are two possible solutions:
Enter your new password into the program by manipulating with the scheduled job Properties
Ask the IT technicians to create a special user with a permanent password
Here is how you can change the User:
Point the mouse over the program name, Right click and select Properties from the drop-down menu.
Click on Change User…
Type the new user name and click OK
There can be many variations of the solution shown above:
The process can be enveloped into a batch file and that program can be triggered from the Task scheduler
Several processes can be incorporated into a Windows Script File called from Task scheduler
CONCLUSION
This paper offers one of the many possible solutions on how to move the repetitive processes away from the regular work hours, reducing the load of the servers during the work time and giving yourself a chance to use your time in a more efficient way. Adding this tip into your arsenal will only increase your value as a highly productive programmer desirable for any team to be part of.
REFFERENCES
Faron Kincheloe. 2008 “While You Were Sleeping - Scheduling SAS® Jobs to Run Automatically”. Available http://www2.sas.com/proceedings/sugi27/p276-27.pdf
ACKNOWLEDGMENTS
Special thanks to Jose Santiago, IT Technician at BCB-ORS for his help.
CONTACT INFORMATION
Your comments and questions are valued and encouraged. Contact the author:
Teo Gamishev
BCB - Office of Research and Statistics
1919 Blanding Street
Columbia, SC 29201
gamishev@hotmail.com
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS
Institute Inc. in the USA and other countries. ® indicates USA registration.
Other brand and product names are trademarks of their respective companies.
No comments:
Post a Comment