BookmarkSubscribeRSS Feed
RaSha
Calcite | Level 5

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.

7 REPLIES 7
SASKiwi
PROC Star

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?

RaSha
Calcite | Level 5
Thanks for your reply, part of my code needs to be run from one id and do the processing. Later, output files of this code needs to be transferred to another server using the separate ID.

I am ok to switch profiles in an EG session as the output files from the first part of code will be permanently saved, do you know a way to switch profiles via code.

Many thanks
RaSha
Calcite | Level 5
##- Please type your reply above this line. No attachments. -

Thanks for your reply..

We use sftp protocol and SSH keys for that
Patrick
Opal | Level 21

@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

 

Kurt_Bremser
Super 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.

ChrisNZ
Tourmaline | Level 20

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1511 views
  • 2 likes
  • 5 in conversation