SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
JDMTX
Fluorite | Level 6

I need to obtain the user id and if possible the user name and e-mail address of the user who is running a job in Enterprise Guide via a workspace server.

At this time, I am considering using proc metaoperate or a call to the macros dictionary table.  Do I have anyother options and what is the recommended best practice?

Many Thanks,

JDM

5 REPLIES 5
SASKiwi
PROC Star

For any SAS EG session you can do this:

data ids;

  length name $ 16 purpose $ 40;

  label name="Value Name" purpose="Purpose";

  infile datalines dsd;

  input name purpose;

datalines;

SYSUSERID, SAS session host account

_CLIENTUSERID, Windows user ID in SAS EG

_CLIENTUSERNAME, Windows user name in SAS EG

_METAUSER, SAS metadata user ID

run;

proc sql;

  select t1.name,

    t2.value,

    t1.purpose

   from work.ids t1

   inner join sashelp.vmacro t2 on (t1.name = t2.name);

quit;

You can also query SAS metadata like so:

options metaserver=sasmetadata metauser="sasadm@saspw" metapass="password";

%mduextr(libref=work);

This gives you all users and their details defined in the SAS metadata - do you want a snapshot of all EG users who are currently connecting to a SAS workspace server, or just all users who are defined in metadata?

JDMTX
Fluorite | Level 6

Great idea on the %mduextr macro!!!  It kills me to embedded the metapass in open code though.

SASKiwi
PROC Star

You could encrypt it then:

proc pwencode in='password';

run;

Then paste the output from the procedure into your metapass string. This does not stop anyone using the encrypted password in code but would prevent them using it in a user tool like SAS Management Console.

ChrisHemedinger
Community Manager

If you are using SAS Enterprise Guide and querying metadata "as you", you don't need the META* options (including the password).  But if you are needing to use a different identity (such as sasadm@saspw), then you do need it.  See this article:

Five strategies to eliminate passwords from your SAS programs - The SAS Dummy

Chris

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
SASKiwi
PROC Star

That's an excellent tip Chris!

%mduextr(libref=work); works fine without the metadata credentials when run in EG. I had just assumed credentials were required because it was in an example on SAS Support.


sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 5 replies
  • 13423 views
  • 3 likes
  • 3 in conversation