/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Macro usage Note: Instead of coding user/password into code like: --> libname dmorp101 oracle PATH="PMIB" SCHEMA=P_DRS defer=yes user="P_RSI_CI" pw="Z75AftgTb" buffsize=12000 dbindex=yes ; Make a macro call at that user/password positon in the code. --> libname dmorp102 oracle PATH="PMIB" SCHEMA=P_DRS defer=yes %xkeypsw(PMIB) buffsize=12000 dbindex=yes ; The desing is simple. Use the a save location on the system (operating system home folder). Read the file being SAS encrypted dataset (read password). You need to be able to use SAS and the have access to that location. Notes: - do not use a ; (semicolon) after the macro-call. - The interactive prompts on password protected datasets do not work having a remote session. EGuide, SAS studio is unaware of the need giving an interactive prompt. Editng a password protected dataset interactively is problematic. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ Sample to create SAS dataset; Data lib.keypswd (read=P1jkU7r write=secret-me alter=secret-me) ; length id $ 16 keypsw $ 32 ; id="orion" ; keypsw="test app" ; output; id="PMIB" ; keypsw='user="P_RSI_CI" pw="Z75AftgTb"' ;output; run; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* * * xkeypswd * * * */ /* * * read personal key-pswd to acess external dbms * * * */ /* * * Goal isolated savev location that is managable instead of hidden * * * */ /* * * written by:jakarman * * * */ /* * * designed 2007 (SAS 8.2) converted 2012 (SAS 9.-) * * * */ %macro xkeypsw ( mainarg,opt,readvl=P1jkU7r,keypswfl=lib.keypswd) ; %local larg lind xkeypswdret ; %let opt =%lowcase(&opt) ; %let larg=%length(&mainarg) ; %let lopt=%length(&opt) ; %let xkeypswdret=; %if ( %index(&opt,HELP) >0 | %index(&opt,?) >0 | %index(&mainarg,?) >0 ) %THEN %do ; %* (insert your comment as copied this sample source) ; %let xkeypswdret=help text given ; %end ; %if ( %length(&xkeypswdret) = 0) %then %do ; %let keydsid=%sysfunc(open(&keypswfl ( read=&readvl where=( id = "&mainarg") ) ,i )); %if (&keydsid = 0) %then %put %sysfunc(sysmsg()); %else %do ; %let rc=%sysfunc(fetch(&keydsid )); %if ( &rc ne 0) %then %put %sysfunc(sysmsg()) ; %let pw=%sysfunc(getvarc(&keydsid, %sysfunc(varnum(&keydsid,keypsw)))) ; &pw %end ; %if ( &keydsid > 0 ) %then %let rc=%sysfunc(close(&keydsid)) ; %end; %mend ;