Systask
Executes, Lists, or Terminates Asynchronous Tasks
Valid in: Anywhere In A Sas Program Windows Specifics: All
Syntax
SYSTASK COMMAND "Host-Command" SYSTASK LIST <_ALL_ | TASKNAME> SYSTASK KILL TASKNAME Command Executes the Host-Command List Lists Either a specific Active Task or all of the active tasks in the system. Kill Forces the Termination of the specified task (s). Host-Command specifies the name of a Windows command (including any command-specific options) Enclose the command in either single or double quotation marks If the command options require quotes, repeat the quotes For example...: SYSTASK Command "Find" "My text" "C: /MYDIR/myfile.sas" Note: The Host-Command That You Specify Cannot Require Input from The Keyboard. Wait | NOWAIT determines whether SYSTASK COMMAND suspends execution of the current SAS session until the task has completed. NOWAIT is the default. For tasks that are started with the NOWAIT argument, you can use the WAITFOR statement when necessary to suspend execution of the SAS session until the task Has finished. TaskName = TaskName specifies a name that identifies the task. Task names must be unique among all active tasks. A task is active if it is running, or if it has completed and has not been waited for using the WAITFOR statement. Duplicate task names generate an error in The sas log. if you do not specify a task name, systematically generate a name. if the task name contacts a blank character, enclose the task name in quotes.mname = name-var specifies a macro variable in which you want SYSTASK to store the task name that it automatically generated for the task. If you specify both the TASKNAME option and the MNAME option, SYSTASK copies the name you specified with TASKNAME into the variable that you specified with MNAME . Status = stat-var Spectifies a Macro Variable in Which You Want Systask to Store The Status of The Task. Status Variable Names Must BE Unique Among All Active Tasks. Shell <= "Shell-Command"> Specifies That the host-command should be executed with the host shell command If you specify a shell-command, SYSTASK uses the shell command that you specify to invoke the shell;.. otherwise, SYSTASK uses the default shell Enclose the shell command in quotes. _All_ Specifies All Active Tasks in The System. State . Statvar Spectation..................... Details SYSTASK allows you to execute host-specific commands from within your SAS session or application. Unlike the X statement, SYSTASK runs these commands as asynchronous tasks, which means that these tasks execute independently of all other tasks that are currently running. Asynchronous tasks run in The Background, So You Can CAN Perform Additional Tasks While The Asynchronous Task Is Still Running.For Example, To Copy A Sas Program, You Might Use this Statement: SYSTASK Command "Copy myprog.sas myprog1.sas" TaskName = "copyfile" status = copyspace; The Return Code from The Copy Command Is Saved in The Macro Variable CopyFile. NOTE: Windows Command Output Is Not Written to The Sas Log. Program steps that follow the SYSTASK statements in SAS applications usually depend on the successful execution of the SYSTASK statements. Therefore, syntax errors in some SYSTASK statements will cause your SAS application to abort. There isks That Can Be Run with Systask: Task All tasks started with SYSTASK COMMAND are of type Task. For these tasks, if you do not specify STATVAR or STATE, then SYSTASK LIST displays the task name, type, and state, and the name of the status macro variable. You can use SYSTASK Kill to Terminate Only Tasks of Type Task. SAS / Connect Process Tasks started from SAS / Connect with the SYSTASK BEGIN statement are of type SAS / Connect Process. For SAS / Connect processes, SYSTASK LIST displays the task name, type, and state. You can not use SYSTASK KILL to terminate a SAS / Connect process. For Information On Starting Sas / Connect Processes with Systask, See SAS / Connect User's Guide. The SYSRC macro variable contains the return code for the SYSTASK statement. The status variable that you specify with the STATUS option contains the return code of the process started with SYSTASK COMMAND. To ensure that a task executes successfully, you should monitor both the status of the SYSTASK statement and the status of the process that is started by the SYSTASK statement.If a SYSTASK statement can not execute successfully, the SYSRC macro variable will contain a non-zero value. For example, there may be insufficient resources to complete a task, OR The Systask Statement May Contain Systax Errors. with The Systask Kill Statement, if One or more of the process, sysrc is set to a non-zero value. When a task is started, its status variable is set to NULL. You can use the status variables for each task to determine which tasks failed to complete. Any task whose status variable is NULL did not complete execution. See WAITFOR for more information about the Status variables. Unlike the x statement, you cannot Use the systask statement to start a new interactive session. See Also Statement: Waitfor Statement: X