Search notes:

SAS statements: systask

systask command

Unlike the x statement, systask writes the output of a shell command to the log file.
systask
  command "ls -l %sysfunc(getoption(work))"
  status  = rc_ls
  wait;

%put &=rc_ls; /* RC_LS=0 */

systask
  command "touch /cannot/touch/this/file/because/directory/does/not/exist"
  status  = rc_ls
  wait;

%put &=rc_ls; /* RC_LS=1 */
Github repository about-SAS, path: /programming/statements/systask/command/status.sas
It seems that for redirection to work, the entire command (inclusive redirection) must be enclosed in something like bash -c 'command > dest-file or alternatively the shell=… parameter can be used.
%let dest=/tmp/tq84.txt;
%let cmd=echo abc def ghi>&dest;

systask command "&cmd"       wait;
systask command "cat &dest"  wait;
/* cat: /tmp/tq84.txt: No such file or directory */

systask command "bash -c '&cmd'" wait;
systask command "cat &dest"      wait;
/* > abc def thi */

systask command "rm &dest"       wait;
systask command "&cmd"           wait shell='bash';
systask command "cat &dest"      wait;
/* > abc def thi */
Github repository about-SAS, path: /programming/statements/systask/command/redirection.sas

systask list

Show all active tasks in the system:
systask list;

See also

SAS statements
shellCmd

Index