Dear SAS community,
I hope you could help me in the following:
I have created a batch .cmd file, where I execute multiple SAS codes. This batch perfectly works if I do simply double click on it.
Now I tried to run the batch via the Task Scheduler. And sometimes it works, and sometimes I get an error "sas.exe has stopped working". This error happens only for the second part of the .cmd, meaning that the first part, which includes one SAS code executes just fine, but the second SAS execution crashes. And this is happens from time to time, while testing I observed crashes in 70-80% of executions.
Here is my .cmd file:
set file_path=XXX
set file_path_log =XXX_log
set file_path_lst=XXX_lst
"\\vm19003\c$\program files\SASHome\SASFoundation\9.4\sas.exe" -sysin "%file_path%.sas" -LOG "%file_path_log%" -PRINT "%file_path_lst%" -NOSPLASH -NOLOGO -ICON
TIMEOUT /T 10
::----------------------------------------------------------------------
set file_path=YYY
set file_path_log =YYY_log
set file_path_lst=YYY_lst
"\\vm19003\c$\program files\SASHome\SASFoundation\9.4\sas.exe" -sysin "%file_path%" -LOG "%file_path_log%" -PRINT "%file_path_lst%" -NOSPLASH -NOLOGO -ICON
exit /b
And here is the Task Scheduler action:
cmd.exe/c "Path_to_cmd_file"
Looking forward for your recommendations!
Sergey
Always hard to understand when it doesn't work sometimes. Try find additional logs that might shed some more light over the issue.
Things to look out for:
- the account used by Windows Task != yours
- if using system account, usually it's hard to access UNC (file shares) locations
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.