Hi All,
We have external passwords (ex: Db2) with % & = and other special chars. how can we mask these or overcome from this issue. SAS doesn't like % & as it is related to macro.
Thanks,
SS
Most places where you put a password in SAS code you can enclose the password in quotes. If you use single quotes then the macro processor will ignore it.
You could for example include the quotes into the macro variable.
%let pwd='adsf&adsf%aas';
Then when you can use it to generate SAS code
libname mylib odbc .... pwd=&pwd ;
If you have managed to get the value into the PWD macro variable without the quotes you can use the %SYSFUNC() macro function to call the QUOTE() function to add the single quotes.
libname mylib odbc .... pwd=%sysfunc(quote(%superq(pwd),%str(%'))) ;
I wouldn't be putting quotes around metadata-stored passwords like in authdomains as SAS wouldn't be able to tell if it is part of the password or not. Why don't you just try such a password without quotes in an authdomain and see if it works or not?
@sathya66 wrote:
Thanks for this . how can we use the same password in AUTH domains? can we use encrypted passwords in Authdomains (pwencode)
I believe using proc pwencode to encode your password and then use this encoded pw for the user in SAS metadata that connects to the DB via the authdomain definition should work.
Not sure if you can use anything above method SAS002. PROC PWENCODE
Why don't you just give it a try?
Or could try this one :
%let pwd= adsf&adsf%aas ; libname x odbc dsn=xx password="%nrbquote(&pwd)" ..........;
Storing passwords in code is a bad idea. Always.
In 9.x SAS allows storing additional accounts in metadata, so you can use authdomain in the libname statement instead of username an password. Afaik the server you want to connect to, has to be defined in metadata, too. So the setup requires an admin.
By all means, avoid handling and/or storing credential information, particularly passwords, in code.
Unless you intend to have a rather unpleasant conversation with your CISO.
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.
Find more tutorials on the SAS Users YouTube channel.