I'd like to execute more SAS codes automatically and orderly.
Follow code(all_codes.sas) can run successfully in Window SAS. However it failed in Unix when I used command: sas94 all_codes.sas in Putty.
%macro all_codes;
data _null_;
systask command "sas &QCPROG.qc_SDTM_ex.sas" taskname="ex" ;
systask command "sas &QCPROG.qc_SDTM_ec.sas" taskname="ec" ;
systask command "sas &QCPROG.qc_SDTM_ds.sas" taskname="ds" ;
waitfor _all_ ex ec ds ;
run;
%mend deal_codes;
%deal_codes;
Could anybody do me a favor? Thanks in advance.
Re my comment #3: If you are running in a Windows terminal, you may not be able to start a session in another window, using the X command. Try instead the pipe approach suggested by @Kurt_Bremser
Re #5: Sorry, I did not mean to try and start a SYSTASK outside the SAS System. It should have been outside the macro. It is often easier to make Things work if you try first without the macro calls.
Could try the x command as below
%macro all_codes;
data _null_;
x "sas &QCPROG.all_codes.sas" ;
x "sas &QCPROG.qc_SDTM_ex.sas";
x "sas &QCPROG.qc_SDTM_ec.sas" ;
x "sas &QCPROG.qc_SDTM_ds.sas" ;
run;
%mend deal_codes;
%deal_codes;
A couple of questions:
Re my comment #3: If you are running in a Windows terminal, you may not be able to start a session in another window, using the X command. Try instead the pipe approach suggested by @Kurt_Bremser
Re #5: Sorry, I did not mean to try and start a SYSTASK outside the SAS System. It should have been outside the macro. It is often easier to make Things work if you try first without the macro calls.
Start by catching all system responses to a command:
filename oscmd pipe "sas &QCPROG.qc_SDTM_ex.sas 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
Look at the log and see what you got.
Once you know what really happens, we can devise ways to work around your problem.
Note that the filename pipe is the best method to run external commands.
Also note that systask and waitfor are global statements and do not need a data step to run.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.