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\
call c:\software\Notepad.exe C:\folder2\

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\

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

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

Leave a Reply

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

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

Facebook photo

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

Connecting to %s

%d bloggers like this: