BookmarkSubscribeRSS Feed
nwelke
Fluorite | Level 6
Hi All,

I'm trying to create a user session table (a text file would also be fine) for managing user sessions, in particular for correlating orphan processes and work libraries to users. I'm trying to have each EG user session update a table that contains four pieces of information - the user, the PID, the start date and time, and the work library path. The code below generates the table, but when i put it into my workspace server's autoexec_usermods.sas my EG session can't see any libraries (the library icon in the server tree view is visible, but when i try to expand it the + just disappears without showing any libraries).

Has anyone built something similar, or used a mechanism other than the autoexec_usermods.sas to run code for each EG user session?

Thanks,
Nick

data myinfo;
length pid $ 8 user $ 16;
pid="&sysjobid";
user="&sysuserid";
sdate="&sysdate";
stime="&systime";
length work $ 255;
work=&sasworklocation;
run;

libname t '/usr/local/sasv9/EBI9.2/Lev1/SASApp/pidlog';

proc append base=t.pidlog data=myinfo force;
run;
libname t;
4 REPLIES 4
ChrisHemedinger
Community Manager
Nick,

Autoexec processing is too early in the process to have the effect you want.

You would need to add this to the "Submit statements when server connected" option within EG's Tools->Options->SAS Programs. I know that's tricky to do for a whole bunch of users, but you need this to happen from EG after the SAS session is established and EG has created its macro variables (like &sasworklocation).

You might be able to store the program in a central location, and add a %include statement to the "Submit statements" option. Then if you have to change the program later, you don't need to hit all of those desktops.

Chris
SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
TimB_SAS
SAS Employee
You can use your code in an autoexec with one minor change - as Chris noted, the EG macro variables will not be available, but you can use:

work=pathname('WORK') ;

to get the location of the SAS WORK library for the session.
CameronLawson
Obsidian | Level 7
We did something similar in the appserver autoexec with 9.1. We recorded the Process ID, Work Path and User ID etc. Basically whenever a user initiated a session with SAS from any client application that used the autoexec you got a record. The dataset grew really fast and we had some issues with causing DI jobs running in parallel to fail. It was fun to see the people who like to open 10 sessions of EGuide at once though 🙂
Selcuk
Calcite | Level 5

Hi Cameron ,

The implementation you have mentioned is what I need... I need to get PID , session login time , log off time , userID etc. But I dont have any idea about how I can get these for every EG session ? If you can help me , I will be realy grateful.

Thank you

Selçuk.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 4857 views
  • 1 like
  • 5 in conversation