This example illustrates the following:
-
encoding a password and saving it to an external
file
-
reading the encoded password with a DATA step, storing it in a
macro variable, and using it in a SAS/ACCESS LIBNAME statement
|
filename pwfile 'external-filename' |
|
proc pwencode in='mypass1' out=pwfile;
run; |
|
filename pwfile 'external-filename'; |
|
options symbolgen; |
|
data _null_;
infile pwfile obs=1 length=l;
input @;
input @1 line $varying1024. l;
call symput('dbpass',substr(line,1,l));
run; |
|
libname x odbc dsn=SQLServer user=testuser password="&dbpass"; |
28 data _null_;
29 infile pwfile obs=1 length=len;
30 input @;
31 input @1 line $varying1024. len;
32 call symput('dbpass',substr(line,1,len));
33 run;
NOTE: The infile PWFILE is:
File Name=external-filename,
RECFM=V,LRECL=256
NOTE: 1 record was read from the infile PWFILE.
The minimum record length was 20.
The maximum record length was 20.
NOTE: DATA statement used (Total process time):
real time 3.94 seconds
cpu time 0.03 seconds
34 libname x odbc
SYMBOLGEN: Macro variable DBPASS resolves to {sas002}bXlwYXNzMQ==
34 ! dsn=SQLServer user=testuser password="&dbpass";
NOTE: Libref X was successfully assigned as follows:
Engine: ODBC
Physical Name: SQLServer
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.