Hi,
I want to identify the mail ID from windows username in SAS. In .NET I have the code for same as below:-
System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress()
But I am not able to find any solution in SAS. Please help!
Thanks.
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;
input;
call symput('current_email',_infile_);
run;
Assuming you have priviledge to access Active Directory properties then DSGET/DSQUERY:
https://technet.microsoft.com/en-us/library/cc732535(v=ws.11).aspx
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.
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?
There are a million reasons why someone would want to send an email thru SAS. That's why he's searching for a way to find out the email given a userid. For example, it's useful for alerts. Attachments are useful to send from SAS as well, with the outputs or the logs of a job just so some key people are informed of the results of a process and if there was failure or what not.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.