Architecting, installing and maintaining your SAS environment

A custom task to list and stop active SAS sessions

Accepted Solution Solved
Reply
Community Manager
Posts: 2,768
Accepted Solution

A custom task to list and stop active SAS sessions

Looking for a convenient way to list and even stop SAS sessions from within SAS Enterprise Guide?  Here's a custom task that allows you to accomplish that.

 

The task uses PROC IOMOPERATE to retrieve the list of spawned SAS sessions (those known by the SAS Object Spawner).  In the task, you can select any of the SAS sessions and stop it (kill the process) -- also accomplished with PROC IOMOPERATE.  Here's an example of what the task looks like:

 

spawnedprocesses.png

 

When you select Show Details, you can see more attributes of the selected SAS process:

 

processprops.png

 

I've attached the custom task DLL (in SasSpawnedProcesses.zip) along with instructions for how to install it to your machine.  I've also made the source code for the task available on GitHub.

 

You can learn more about the task and PROC IOMOPERATE from these blog posts.  Please -- let me know if you find the task useful!

 

Attachment

Accepted Solutions
Solution
2 weeks ago
Community Manager
Posts: 2,768

Re: A custom task to list and stop active SAS sessions

There have been a handful of fixes to DOSUBL and related functions since 9.4M2, but I can't say that any of these are the cause of the problem.  I suggest that you work with SAS Tech Support on this one -- maybe they can come up with the cause and a workaround.

View solution in original post


All Replies
Contributor Go
Contributor
Posts: 58

Re: A custom task to list and stop active SAS sessions

I get below error chris...see red highlighted

 

 

1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %let connection = 'iom://psasmetal4.juniper.com:8581;bridge;user=sasadm,pass=XXXX';proc iomoperate uri=&connection.;
NOTE: The CONNECT command completed.
4 list spawned out=spawned;
NOTE: The data set WORK.SPAWNED has 0 observations and 5 variables.
NOTE: The LIST SPAWNED SERVERS command completed.
5 quit;

NOTE: PROCEDURE IOMOPERATE used (Total process time):
real time 0.18 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 624.34k
OS Memory 13220.00k
Timestamp 11/29/2016 04:58:07 PM
Step Count 26 Switch Count 103
Page Faults 2
Page Reclaims 126
Page Swaps 0
Voluntary Context Switches 507
Involuntary Context Switches 37
Block Input Operations 0
Block Output Operations 0

6
7 data _null_;
8 set spawned;
9 length y $ 3;
10 y = put(_n_,z3.);
11 x = dosubl("
12 proc iomoperate uri=&connection. launched='" || serverid || "';
13 list attrs cat='Information' out=pids" || y || ";
14 quit;
15 data pids" || y || ";
16 set pids" || y || ";
17 length sname $30;
18 sname = substr(name,find(name,'.')+1);
19 run;
20
21 proc transpose data=work.pids" || y || "
22 out=work.tpids" || y || "
23 ;
24 id sname;
25 var value;
26 run;
27 ");
28 run;

NOTE: There were 0 observations read from the data set WORK.SPAWNED.
NOTE: DATA statement used (Total process time):
real time 0.13 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 1281.31k
OS Memory 13220.00k
2 The SAS System 16:47 Tuesday, November 29, 2016

Timestamp 11/29/2016 04:58:07 PM
Step Count 27 Switch Count 108
Page Faults 1
Page Reclaims 143
Page Swaps 0
Voluntary Context Switches 371
Involuntary Context Switches 3
Block Input Operations 0
Block Output Operations 0

29
30 data _allpids_;
31 set tpids:;
ERROR: The data set list (WORK.tpidsSmiley Happy does not contain any members.
32 length StartTime 8;
33 format StartTime datetime20.;
34 starttime = input(UpTime,anydtdtm19.);
35 run;

NOTE: Numeric values have been converted to character values at the places given by: (Line)Smiley SadColumn).
34:23
NOTE: Compression was disabled for data set WORK._ALLPIDS_ because compression overhead would increase the size of the data set.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK._ALLPIDS_ may be incomplete. When this step was stopped there were 0 observations and 2 variables.
WARNING: Data set WORK._ALLPIDS_ was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.05 seconds
user cpu time 0.00 seconds
system cpu time 0.01 seconds
memory 724.84k
OS Memory 13220.00k
Timestamp 11/29/2016 04:58:07 PM
Step Count 28 Switch Count 52
Page Faults 0
Page Reclaims 18
Page Swaps 0
Voluntary Context Switches 166
Involuntary Context Switches 6
Block Input Operations 0
Block Output Operations 0

36
37 proc datasets lib=work nolist;
38 delete tpids:;
39 delete spawned;
40 quit;

NOTE: The file WORK.TPIDS: (memtype=DATA) was not found, but appears on a DELETE statement.
NOTE: Deleting WORK.SPAWNED (memtype=DATA).
NOTE: PROCEDURE DATASETS used (Total process time):
real time 0.01 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 230.84k
OS Memory 12704.00k
Timestamp 11/29/2016 04:58:07 PM
3 The SAS System 16:47 Tuesday, November 29, 2016

Step Count 29 Switch Count 36
Page Faults 1
Page Reclaims 1
Page Swaps 0
Voluntary Context Switches 91
Involuntary Context Switches 2
Block Input Operations 0
Block Output Operations 0

41
42 QUIT; RUN;
43

Contributor
Posts: 36

Re: A custom task to list and stop active SAS sessions

I love this task..... At least what I can see in the blogpost :-)

 

When I run the task, I'm getting an error:

ERROR: Requested function is not implemented.
ERROR: Unsupported function
ERROR: The LIST ATTRIBUTES command failed.

 

I've narrowed it down to the dosubl-function. The list attributes works on it's own.

What's wrong..... Do I have to do something special to use this function?

 

Community Manager
Posts: 2,768

Re: A custom task to list and stop active SAS sessions

DOSUBL has had a few improvements / fixes over the recent releases.  Can you tell us what version of SAS you're running?  PUT &SYSVLONG...

Contributor
Posts: 36

Re: A custom task to list and stop active SAS sessions

We're running on 9.04.01M2P072314

 

Community Manager
Posts: 2,768

Re: A custom task to list and stop active SAS sessions

I suppose that it's possible that in your environment, there is a server process that doesn't support the "Category" attribute method.  That's a guess -- not sure what that would be.  You might need to break it down by running the programs from this post. 

Contributor
Posts: 36

Re: A custom task to list and stop active SAS sessions

Thank you for your time!

 

That's just what I did. I used the code in the link and tested what worked and what didn't.

The list attrs  works fine when I use it in the PROC IOMOPERATE.

 

proc iomoperate uri=&connection.; 
    list attrs cat='Information';
    quit;

 

But running the following code results in the error

/* Get a list of processes */
proc iomoperate uri=&connection.;
    list spawned out=spawned;
quit;

 
/* Use DOSUBL to submit a PROC IOMOPERATE step for   */
/* each SAS process to get details                   */
/* Then use PROC TRANSPOSE to get a row-wise version */
data _null_;
    set spawned;
    /* number each output data set */
    /* for easier appending later  */
    /* TPIDS001, TPIDS002, etc.    */
    length y $ 3;
    y = put(_n_,z3.);
    x = dosubl("
    proc iomoperate uri=&connection. launched='" || serverid || "';
    list attrs cat='Information' out=pids" || y || ";
    quit;
    data pids" || y || ";
    set pids" || y || ";
    length sname $30;
    sname = substr(name,find(name,'.')+1);
    run;
 
    proc transpose data=work.pids" || y || "
    out=work.tpids" || y || "
    ;
    id sname;
    var value;
    run;
    ");
run;

 

 

 

  

Solution
2 weeks ago
Community Manager
Posts: 2,768

Re: A custom task to list and stop active SAS sessions

There have been a handful of fixes to DOSUBL and related functions since 9.4M2, but I can't say that any of these are the cause of the problem.  I suggest that you work with SAS Tech Support on this one -- maybe they can come up with the cause and a workaround.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 1558 views
  • 11 likes
  • 3 in conversation