i use two macro's (one called from within another) to check 1. that the data set exists that i am going to upload to LASR if it doesnt (fails to be created), then i email myself 2. if it does exist, drop the current table in LASR 3. load the data from work to LASR here is the code i use. the macro call at the bottom gets it all rolling: LIBNAME LASRLIB META Library="Visual Analytics Public LASR" METAOUT=DATA; /* Remove existing table from LASR if loaded already */ %macro deletedsifexists(lib,name); %if %sysfunc(exist(&lib..&name.)) %then %do; %put DeletDSifExistsMacro; proc datasets library=&lib. nolist; delete &name.; quit; %end; %mend deletedsifexists; /*Macro to check to see if expected dataset exists and if so, then do stuff*/ %macro CheckResult(Slib,Sname,Tlib,Tname,email); %PUT Source Data &Slib..&Sname.; %PUT Target Data &Tlib..&Tname ; %if %sysfunc(exist(&Slib..&Sname.)) %then %do; %put CheckResultMacro; %deletedsifexists(&Tlib, &Tname); /* Loading through the SASIOLA Engine */ data &Tlib..&Tname ( ); set &Slib..&Sname ( ); run; %end; %else %do; %put Expected dataset does not exists (&Slib..&Sname.), need to email someone; filename mailbox email TO=(&email) FROM=('NoReply <NOREPLY@CompanyName.com>') SENDER = ('NoReply <NOREPLY@CompanyName.com>') IMPORTANCE='HIGH' replyto='NOREPLY@CompanyName.com' Subject='SAS VA Dataset Loading Failed'; DATA _NULL_; FILE Mailbox; PUT "Greetings,"; PUT " This is a message from a SAS."; PUT "Expected dataset does not exists (&Slib..&Sname.)"; PUT "may need to do something"; RUN; %end; %mend CheckResult; /*SourceLib, SourceTab, TargetLib, TargeTab, email addresses*/ %CheckResult(work, TableNameInWork, LASRLIB, TableNameInLASR, 'person@CompanyName.com' );
... View more