Hello,
usually, control-M will execute a Kernel Script hosted on our Unix server, then passed few parameters such as the order date, and finally, we use a sysparm command to pass the order date and execute a specific sas code.
I wonder if there is a way to trigger a control-M job such a file transfer, via a SAS code.
If so, please provide an example.
The X and %Sysexec statements, System and Call System functionswill execute operating system instructions. So would work to execute a known script as you would provide that as part of the call. HOWEVER, many SAS shops disable the functionality of these statements.
Wouldn't it just be a lot easier to use the Control-M user interface?
The purpose of a tool like Control-M is that EVERYTHING is run FROM THERE.
Have all dependencies implemented in the scheduler; if you need to react to the result of a SAS job, use clearly defined exit codes for this.
Yes. SAS will set the error code when it exits, which you can then test.
In this example the error code was set to 5:
1? options errorabend; 2? data x.y.z; run; 2 data x.y.z; run; ----- 211 ERROR 211-185: Invalid data set name. NOTE: The SAS System stopped processing this step because of errors. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds ERROR: SAS ended due to errors. You specified: OPTIONS ERRORABEND;. NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414 NOTE: The SAS System used: real time 17.24 seconds cpu time 0.04 seconds >echo $? 5
Or you can use the ABORT statement with the RETURN option and return an error number you want.
Example:
>sas -noautoexec -nodms ... NOTE: SAS initialization used: real time 0.06 seconds cpu time 0.03 seconds 1? data _null_; abort return 27; run; ERROR: Execution terminated by an ABORT statement at line 1 column 14, it specified the RETURN option. _ERROR_=1 _N_=1 NOTE: The SAS System stopped processing this step because of errors. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414 NOTE: The SAS System used: real time 13.24 seconds cpu time 0.03 seconds >echo $? 27
Now you just need to ask the makers of that other software how to detect the return code of a program you used it to run.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.