Hello,
I'm trying to understand the behavior of parallel sessions (I'm using a SAS Enterprise Guide).
In my example I'm using SIGNON and RSUBMIT WAIT=NO.
In my test:
- the main session creates a few files (server_first, server_mid, server_last);
- in parallel, a remote session is started which progressively creates the remote_i files with a 5-second pause between each iteration (sleep function).
option sascmd="sas";
%let save_path = path1\path2\path3;
data "&save_path\server_first";
var=1;
run;
signon task1;
rsubmit task1 wait=no;
%let save_path = path1\path2\path3;
%macro create_table;
%do i=1 %to 10;
data "&save_path\remote_&i";
a=&i;
run;
%let sleep_var = %sysfunc(sleep(5));
%end;
%mend;
%create_table;
endrsubmit;
data "&save_path\server_mid";
var=1;
run;
waitfor _all_;
signoff _all_;
data "&save_path\server_last";
var=1;
run;
During execution, after the creation of remote_2, I stopped the run from SAS Enterprise Guide. From what I observed:
- the main session is effectively interrupted (for example, server_last is not created);
- the remote session keeps running independently and completes the creation of all the remote_i files.
So, it seems that the remote session remains independent from the main one. Is it correct?
I would like to ask if there is a way to interrupt the remote sessions even after the main session has been interrupted. I know there are commands such as KILLTASK and LISTTASK, but I'm not sure whether they are relevant in this case.
From the docs, looks like KILLTASK is just what you're looking for:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/connref/p06892khfraoocn1kmcxw9e66ztz.htm
The KILLTASK statement enables users to terminate one or more tasks or server sessions that are executing asynchronously. The KILLTASK statement is useful only for an asynchronous RSUBMIT.
Success might vary a bit depending on IDE and OS. Did you give it a try?
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →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.