I am using SAS Enterprise Guide 6.1 and am utilizing the "Submit SAS Code when server is connected" capability under Tools, SAS Programs to submit all of my personal credentials, libnames. Yes, I know there is probably an easier way to do this with SAS Management Console, but that is not an option right now.
I have several Teradata libraries I need to assign within each project, but the problem is that sometimes I (or more commonly somebody else on my team) will change my password and forget to change it in the start-up code. This results in several incorrect attempts and locks me out immediately. I wish to do a few things:
Create a conditional libname assignment that will execute all the libnames if the credentials are correct.
If the credentials are incorrect, the libnames are not executed (so that I don't lock myself out).
Since the SAS code in the "Submit SAS Code when server is connected" section doesn't seem to generate a log, I wish to send myself an email with the SAS Log attached (only if the credentials fail).
Kill the Server connection (if credentials error out) to avoid further attempts to assign libraries.
Here is my attempt, I'm having trouble attaching the log and setting up the email statement.
*Define personal credentials;
%let [email protected];
filename temp email "&myemail";
*Define Teradata credentials;
%let tera_user=Gollum; /*Teradata Username*/
%let tera_pwd=#filthy_hobbitses; /*Teradata Password*/
*Conditionally assign libraries;
%macro libsetup();
libname library1 teradata user=&tera_user password="&tera_pwd" tdpid=terap schema=library1 fastload=yes bulkload=yes fastexport=yes;
%if &syslibrc=0 %then
%do;
libname library2 teradata user=&tera_user password="&tera_pwd" tdpid=terap schema=library2 fastload=yes bulkload=yes fastexport=yes;
libname library3 teradata user=&tera_user password="&tera_pwd" tdpid=terap schema=library3 fastload=yes bulkload=yes fastexport=yes;
*more library statements here;
%end;
%else
%do;
data _null_;
file temp
subject="TERADATA CREDENTIALS ERROR"
attach=("put SAS LOG filename here");
put 'Teradata Login Failed. SAS LOG Attached.';
%abort abend;
%end;
%mend libsetup;
%libsetup;
Thanks.
PROC PWENCODE
to encrypt it, then embed the encrypted value (e.g.%LET TERA_PWD = {sas002}ax=5qZhw4... ;
) in your code. – Chris J