- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Do you want to write the sysuserid into a data set?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Does %put &SYSUSERID.; not work for you?
In a data set: avariable = "&SYSUSERID.";
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it does not work in a way i want 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can refer to it as per any other macro variable:
%if "&SYSUSERID." = "Me" %then %do;
something
%end;
%else %do;
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Next up: Troy Martin Hughes presents Calling Open-Source Python Functions within SAS PROC FCMP: A Google Maps API Geocoding Adventure on Wednesday April 23.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
%let id=&sysuserid;
%put &id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;