BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

How do i code in SAS to execute a batch file?
4 REPLIES 4
Cynthia_sas
Diamond | Level 26
Hi:
Do you mean execute SAS in batch mode or execute a .BAT file???

I'll answer what I do for the 2nd possibility. When I execute a .BAT or .CMD file on Windows. For example, I have a .BAT file (MYCOPYLIST.BAT) that copies a list of files from one folder to a backup folder. I submit code like this in a SAS program:
[pre]
options noxwait noxsync;
x 'c:\temp\mycopylist.bat';
[/pre]

To find out how to execute SAS in batch mode, you have to consult the SAS Companion for your operating system.
cynthia
deleted_user
Not applicable
Cynthia,

Thats exactly what I do with my batch file. I have a prod.bat on windows. I do not want to click it manually. Rather I would like to code a sas program and schedule it so that it can take care of executing the batch file (runprod.bat). Will this code of yours work for me?
Cynthia_sas
Diamond | Level 26
It depends on whether the X command is allowed (it's not usually allowed for EG, for example.)

I don't use CHRON or a job scheduler. So I assume that if you scheduled the SAS program to run in batch that it would work. But, why not just schedule the .BAT job to run???

You might want to work with Tech Support on this one. Or maybe someone else has experience with batch submitting programs with an X command.

cynthia
Tim_SAS
Barite | Level 11
You can use the Windows Task Scheduler to schedule batch files. For more information, use Google to search for "windows schedule batch file" (without the quotes) or click Start->Help and Support and then enter Task Scheduler in the search box.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 4593 views
  • 1 like
  • 3 in conversation