BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Guofeng
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
s_lassen
Meteorite | Level 14

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.

View solution in original post

7 REPLIES 7
Jagadishkatam
Amethyst | Level 16

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;
Thanks,
Jag
Guofeng
Fluorite | Level 6
Hi Jagadishkatam, I tried it. However the codes like qc_SDTM_ex.sas don't execute in the UNIX and there are no erorrs/warrings.
s_lassen
Meteorite | Level 14

A couple of questions:

  1. Can you start SAS using "sas94 all_codes.sas" from the Shell?
  2. Why do you put your SYSTASK statements after DATA _NULL_? This is not a data step statement, you can use it anywhere.
  3. Can you start your SAS command using an X statement or command? Try that, with OPTIONS XWAIT, then you should be able to see what happens in the Shell window.
  4. In what way does the SYSTASK command fail? Any messages in the log?
  5. Can you start a SAS using SYSTASK outside the SAS system?
  6. What does it mean that you use the command in Putty? that's not a Shell (or is it?), I think it's a file transfer program.

 

Guofeng
Fluorite | Level 6
PuTTY is an SSH and Telnet client for Windows, it can check in/out data in Unix and also can use sas9 xxx.sas to run sas codes.
Guofeng
Fluorite | Level 6
Hi s_lassen, thank you so much for the valuable comments. for comments #3 and #5,could you show me some examples when you have time. I'm not familiar with SYSTASK and command. I often run SAS codes in SAS system.
Sincere appreciation.
s_lassen
Meteorite | Level 14

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.

Kurt_Bremser
Super User

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 1290 views
  • 0 likes
  • 4 in conversation