Hello SAS Fellows, I want to create SAS macro's for WINDOWS environment, which can read system user id (SYSUSERID) as observation. %let ID=%sysget(SYSUSERID); %put &ID; but its not working. I found that SYSUSERID is an Read only automatic variable. Can anyone of you please suggest me something. I am planning to develop an startup macro which can read QC or PROD data as per user's wish.
Sounds like you just are confused about how to reference the value of a macro variable.
If you have a macro variable named SYSUSERID you can reference the value by placing an ampersand in front of the name.
%put User name is &sysuserid ;
If you want to use the value in a data step then treat it the same as any other text literal, except make sure to use double quotes instead of single quotes. Macro expressions are not resolved inside of single quotes.
data log ;
userid = "&sysuserid";
run;
Do you want to write the sysuserid into a data set?
Hi,
Does %put &SYSUSERID.; not work for you?
In a data set: avariable = "&SYSUSERID.";
Yes, it does not work in a way i want 😞
Yes, i want to use my user id in some condition like %let ID=%sysget(&sysuserid); %put &ID; %if &ID = xxxxx %then %do; libname PROD ""; %end; %else %do; libname QC""; %end;
Looks like you seek a solution that makes user-specific library alllocations.
My recommendation would be to prepare a small program for each user, containing the libname statements for them and invoke those in a way similar to:
%INCLUDE "pathToSharedFolder/Libs_&sysuserid..sas" ;
With this approach you need no macro programming.
You are using &SYSUSERID to select the libname code relevant to each user.
Good luck
peterC
The sysuserid is a automatic sas macro-var can be referred to as &sysuserid
You can retrieve windows (dos) environment-setting like: %put %sysget(appdata);
You can refer windows (dos) and sas-config sets in filenname libname like: libname tstme "!homeshare";
The windows (dos) environmentvar is often pointing to your personal share in networkenvironments.
SAS Logging is already containing the involved userid. What is your issue to solve?
Check cyntia-s paper menioned in: https://communities.sas.com/thread/55205
Yes, Correct. I want to call this ID in my program. I am trying with SYSUSERID automatic variable. Is there any other way to refer this in my program.
You can refer to it as per any other macro variable:
%if "&SYSUSERID." = "Me" %then %do;
something
%end;
%else %do;
...
Hi,
Suggest you post the code of the macro you are trying to develop, and also the log from running the macro. May also help people help you if you add
Options Symbogen;
%let id=&sysuserid;
%put &id;
Sounds like you just are confused about how to reference the value of a macro variable.
If you have a macro variable named SYSUSERID you can reference the value by placing an ampersand in front of the name.
%put User name is &sysuserid ;
If you want to use the value in a data step then treat it the same as any other text literal, except make sure to use double quotes instead of single quotes. Macro expressions are not resolved inside of single quotes.
data log ;
userid = "&sysuserid";
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.