BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

Hello,

 

A simple way to connect to an Oracle table is to use the follow SAS code:

 

LIBNAME myora ORACLE PATH=orasrv USER=myuse PW=mypassword:

 

But what is the best way to protect the username and password so nobody can see their values.

Please provide an example. 

5 REPLIES 5
SASKiwi
PROC Star

How secure do you want your password to be? PROC PWENCODE is one option:

proc pwencode in = 'mypassword';
run;

SASKiwi_0-1695337557556.png

Just replace the PW text in your LIBNAME with {SAS002}68B279564BD2695538CDCDB301E8A357563480B0

 

This wont prevent someone just copying and pasting your LIBNAME into their own code though.

 

SASKiwi
PROC Star

Another more secure option is to create a new Authentication Domain in SAS metadata, within a new metadata User Group, then add an Oracle account and password to use for the whole group. You then add all SAS users allowed to access Oracle to this new user group. You need to have administrator access to SAS Management Console to be able to set this up and you also need a shared account for Oracle access - one that is shared across all users in Oracle SAS user group. You would need approval from your IT security folks to obtain this. Your LIBNAME would now look similar to this: 

libname MyOracle Authdomain = OracleAuth;

 

Tom
Super User Tom
Super User

A few methods.

 

Store the password into an environment variable and use %SYSGET() to pass it to the LIBNAME statement.  

LIBNAME myora ORACLE PATH=orasrv USER=myuse PW="%sysget(mypassword)";

Note you might want to use this %QSYSGET() macro if your passwords are messy.

 

Store the password into a file (with proper access permissions) and read from the file to generate the libref.  You could just use it to generate a LIBNAME() function call.

data _null_;
   infile 'mypassword' ;
   input;
   rc = libname('myora','ORACLE',,catx(' ','PATH=orasrv USER=myuser PW=',quote(trim(_infile_))));
run;

For ORACLE try defining an ORACLE WALLET and use that to connect.

mightydron
Calcite | Level 5

Securing passwords in SAS is super important these days. It's like having a guard dog for your online accounts! These tools help you create passwords that are tough for hackers to crack.

mightydron
Calcite | Level 5

One easy way to do it is to use a strong password checker. Here's a tip: try to mix it up with a combo of letters, numbers, and symbols. Avoid using easy stuff like your pet's name or "password123". Plus, don't forget to change your password regularly to keep those sneaky cyber folks guessing. Another cool trick is using two-factor authentication when you can. It adds an extra layer of security, like having a secret code to get into your clubhouse.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2230 views
  • 0 likes
  • 4 in conversation