DATA Step, Macro, Functions and more

Get the users email based on their username

Posts: 71

Get the users email based on their username


I want to identify the mail ID from windows username in SAS. In .NET I have the code for same as below:-



But I am not able to find any solution in SAS. Please help!


Super User
Posts: 10,268

Re: Get the users email based on their username

I'd suggest to write a little .NET program that makes that method/function call and writes the result to standard output.

Then call that program from SAS with

filename oscmd pipe "your_net_program";
data _null_;
infile oscmd;
call symput('current_email',_infile_);
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Super User
Posts: 9,599

Re: Get the users email based on their username

Assuming you have priviledge to access Active Directory properties then DSGET/DSQUERY:


Some examples:


However I would point out that SAS is built to do analysis and processing of data, not for doing administrative tasks on your operating systems, so it sounds like your doing something wrong.  I presume if you are after email then your sending something to someone?  If so then there are far better methods out there - shared network area, sharepoint, report publishing platforms etc.  Sending things via email can be unsecure, and there are limits on what you can send.



Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation