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

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
Rhodochrosite | Level 12

Is &sysuserid what you are looking for?

View solution in original post

Rhodochrosite | Level 12

Is &sysuserid what you are looking for?

Calcite | Level 5

Thanks great, thanks.

Rhodochrosite | Level 12

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;

proc print;

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 (



Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3 in conversation