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

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!

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

10 REPLIES 10
Go
Quartz | Level 8 Go
Quartz | Level 8

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.tpids:) 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):(Column).
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

Matthijs
Obsidian | Level 7

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?

 

ChrisHemedinger
Community Manager

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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Matthijs
Obsidian | Level 7

We're running on 9.04.01M2P072314

 

ChrisHemedinger
Community Manager

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. 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Matthijs
Obsidian | Level 7

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;

 

 

 

  

ChrisHemedinger
Community Manager

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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
webbm
Fluorite | Level 6

We have a user who must have network issues and gets frequently disconnected, leaving rogue sessions and files locked.  I wanted to use this task so he could go in and kill his previous pid, but it doesn't appear that he has access to do that.  He can view the sessions, but he cannot kill them.  

 

I was hoping that I could give this user the ability to deal with his problem without logging tickets.  Is this tool meant for admins only, or could we provide it to end users? The user only sees their own sessions so I thought it was safe, but this error comes up:

ERROR: Access denied.
ERROR: The STOP SPAWNED SERVER command failed.

 

What permissions would I need to apply, and where, to allow users the ability to kill their own processes? 

 

ChrisHemedinger
Community Manager

Since these requests go to the Object Spawner operator interface, I think it's a task usually left to the admin.  In a shell command, a user can usually kill their own processes -- you might need to provide a tool/shell access that allows them to do that.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
webbm
Fluorite | Level 6

Ok gotcha. Thanks for the quick reply. Makes sense...was just trying not to get tickets from end users, but you gave me an idea I will play around with.  

 

 

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 10 replies
  • 7345 views
  • 11 likes
  • 4 in conversation