You can use a data-step to read in a file containing password information, see the following for an example. This code assumes the password file is formatted as username|password
i.e. pipe delimited and only containing one line.
filename pw ""; /*<insert name of pw file here>*/
data _NULL_;
infile pw dlm='|'; /* Change dlm if not pipe */
input
uname : $50.
pw : $50.;
call symputx('uname',uname);
call symputx('pw',pw);
run;
libname xxx odbc user=&uname. password=&pw. dsn=myDsn schema=mySchema;
proc sql;
connect to xxx(dsn=myDsn user=&uname. password=&pw.);
If you are working on a metadata server you can use authentication domains to hold password information instead.
In that case you would alter your password in the metadata and then refer to it in code using the authdomain=
option, which would return the password to SAS without it being displayed.
e.g.
libname xxx odbc authdomain=MY_ODBC_AUTHDOMAIN dsn=myDsn schema=mySchema;