Hi There, I would like to switch profiles (User id) to run parts of code in a single sas session on SAS EG. Any help. Many thanks.
That isn't possible as you are tied to the userid used in your EG profile to create your SAS session. Switching userids means switching EG profiles and starting a new SAS session.
Why do you want to switch userids?
You say that you need the separate ID for file transfer only. How do you transfer the files?
@RaSha - throwing ideas here. Not sure what will work.
Solution options
A If you Google with something like linux run command as another user then you'll get quite a few hits. You're user has most likely no elevated privileges which allow to issue sudo commands but from browsing through some of the discussions it appears an admin could allow your user to sudo a specific command or script so that you can execute as another user. You would need to talk to a linux admin at your site and explain what you need.
B "You" could add the script transferring the file to a scheduler which gets triggered whenever a file arrives in a specific folder. You then just execute your first step creating the file in EG and write the output to this folder. I would assume that that the schedule/batch user has elevated rights and can execute the transfer process under the user you need.
C If you need to go for something where you have user/pw in the code then you could at least have this in a secure compiled macro in the SAS mstore - and you then keep the source code in a safe place.
D Or ideally do what @Kurt_Bremser proposes if that's possible for your user
@RaSha wrote:
##- Please type your reply above this line. No attachments. -
Thanks for your reply..
We use sftp protocol and SSH keys for that
Then you do not need to switch users before running the sftp command. In the ~/.ssh/config file, you can specify connection parameters for each target host, including which user-ID to use.
The only option I can think of is to run the piece of code as a batch job on the server, something like:
call system('runas /user:domainname\username sas.exe -sysin pgm.sas');
or
call system('net use \\svr\shre /USER:usr pwd & \\svr\shre\saspgm.cmd');
Having a password in plain text is very bad practice however.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.