Using Batch Files to Automate

Batch files may be old fashioned but can save you a lot of time in repeated tasks.Here is an example of a batch file that has

1) Some Global variables (Inputs)

set SALES_GRP=s1
set ID=f2
set SALES_DATE=nov0107

#BATCH FILE COMMENT using hash order_date format is monddyy

2) Used notepad to open a file for making changes

call c:\software\Notepad.exe C:\folder1\input1.sas
call c:\software\Notepad.exe C:\folder2\input2.sas

3)Created a directory to store results

call mkdir C:\folder2\%SALES_GRP%\%ID%\%SALES_DATE%

4) Executed another batch file or code using relevant software (eg SAS.exe for SAS Code)

call C:\software\sas8.exe C:\folder1\input1.sas

call C:\software\sas8.exe C:\folder2\input2.sas


5) Changes active folder

call cd C:\folder1

This can particularly help you schedule SAS code running at specific times using Windows Scheduler

Author: Ajay Ohri

http://about.me/ajayohri

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s