Help using Base SAS procedures

Set encrypted READ password in autoexec

Not applicable
Posts: 0

Set encrypted READ password in autoexec

I'm not sure if this is the right forum section for this question, but direct me if I'm in the wrong place.

I've created a process to use SQL server to create a password and store it in a SQL table. Then I've created sas code to read the password value into a variable and then pass it along inside sas script to read a SPDS table.

Now I want to know if its possible to have the variable (and its return value) stored in autoexec, so I don't need to call the READ= code everytime I read a SPDS table.
Maybe I can use READ= value when I define libname inside autoexec?

=========================== Code ===========================
LIBNAME data sasspds host="sas01" serv="5190" user="spdsadm" ip=yes schema= "DATA" password="XXX" compress=yes;

/*** READ ***/
/*** code to auto pull read_key from SQL table ***/
/*** and read SPDS table content ***/
proc sql;
/* Put the resultset (1st row) into a varibale pw */
/* SAS PW is MAX 8 char long, here we take the 1st 8 Chars */
connect to odbc(uid=XXX pwd=XXX dsn="SQLServer03" );
select compress(read_key) into :r_pw from connection to odbc
(select top 1 read_key from DB..SAS_SPDS_KEY);
disconnect from odbc;

options symbolgen;

proc contents data= data.TABLE_1(read=&r_pw);

proc contents data= data.TABLE_2(read=&r_pw);

proc contents data= data.TABLE_3(read=&r_pw);

Trusted Advisor
Posts: 2,125

Re: Set encrypted READ password in autoexec

Posted in reply to deleted_user
I haven't been successful with formally encrypting. We did find an alternative that works for us for batch SAS runs.

We put the LIBNAME in a %INCLUDE file that is only available to the person(s) running the program. (We put it in the user's home directory as we require each individual to use his or her own password.) SAS takes care of converting it to x's for the log and it is never in the .SAS files that others might be able to get to.
Frequent Contributor
Posts: 139

Re: Set encrypted READ password in autoexec

Posted in reply to deleted_user
If your purpose is to mask the password PROC PWENCODE is a usefull method.
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation