Desktop productivity for business analysts and programmers

Logged on User

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Logged on User

I need to identify the user name of the current user from within a Stored Process.  Is there a way of doing this?


Accepted Solutions
Solution
‎07-14-2011 10:41 PM
Valued Guide
Posts: 2,111

Logged on User

Is &sysuserid what you are looking for?

View solution in original post


All Replies
Solution
‎07-14-2011 10:41 PM
Valued Guide
Posts: 2,111

Logged on User

Is &sysuserid what you are looking for?

Occasional Contributor
Posts: 5

Logged on User

Thanks great, thanks.

Super Contributor
Posts: 387

Re: Logged on User

Hi Seer,

There are a number of macro variables you can choose from to best suit your needs, but the values they have will depend on the way in which the stored process is configured, the configuration of the server it will run on, and the person who has logged in to run it.  Generally speaking in a stored process you are probably interested in &_METAUSER or &_METAPERSON which will resolve to the userid and name of the person who logged in to run the stored process.  On the other hand &SYSUSERID will be the userid for the SAS process owner which may or not be the person who is running the stored process.  To give you some examples, I have the following stored process code which will show me the various identity values:

data test;
sysuserid="&sysuserid";
metauser="&_metauser";
metaperson="&_metaperson";
run;

proc print;
run;

If I create a stored process with this code and configure it to I run on my "SASApp - Logical Stored Process Server" then I get the following output when it is run:

sysuserid   metauser   metaperson
---------------------------------
sassrv      paul       Paul Homes

If I then modify it to run on my "SASApp - Logical Workspace Server" I will get the following output when it is run:

sysuserid   metauser   metaperson
---------------------------------
paul        paul       Paul Homes

Notice that &SYSUSERID is different.  That's because my "SASApp - Logical Workspace Server" is configured to launch and run the underlying SAS process on-demand as the requesting user, but my "SASApp - Logical Stored Process Server" is configured to pre-launch SAS processes with a fixed set of launch credentials (the sassrv account often used to run SAS stored process and pooled workspace servers). This is a common configuration. In some situations it is also possible and/or necessary to configure a standard workspace server to use a specific set of launch credentials too so I wouldn't rely on this behaviour unless you talk to you platform administrator first.

I would suggest that whilst it may be possible to use &SYSUSERID in some situations you might be better of using &_METAUSER or &_METAPERSON if you want the identity of the person who logged in to the SAS platform to run the stored process.  I would only use &SYSUSERID when you want the identity of the account used to run the SAS operating system process regardless of who logged into SAS to run the stored process.

There is more information on the special _METAUSER and _METAPERSON macro variables in the SAS® 9.2 Stored Processes: Developer's Guide under Writing a Stored Process and Using Reserved Macro Variables (http://support.sas.com/documentation/cdl/en/stpug/61271/HTML/default/viewer.htm#a003152603.htm)

Cheers
Paul

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 978 views
  • 0 likes
  • 3 in conversation