sassas-macroproc-sql

Condition is not working - Send email SAS GUIDE


I have to do a condition in SAS Guide if the SYSERRORTEXT is blank or not, but the code that I created is giving me only the value 0, indicating that the code is not good, even I received the e-mail. I've tried everything for days, but anything is working. I've tried IS MISSING, IS NULL, " ", LIKE something etc. I've tried the variable SYSERR too, prxmatch('/ERROR\d+/', text) > 0, anything, but it's getting me crazy. How can I get the best code of it? Thank you very much!

%let emails = "eh@kl.com";

filename msg email
to=(&emails)
from="eflkjwh@kl.com"
subject="yurusg"
type="text/html"
attach=('C:\\Temp\\RESULT_VALID_DT_REF_BO.xlsx')
;

ods html file=msg rs=none;

proc odstext;
p " ";
p "Olá, ";
p " ";
p "Segue em anexo o resultado da validação da DT_REFERENCIA_BO nas entidades CONTRATO e CONTA. ";
p " ";
p "Obrigada. ";
run;
ods html close;

%END;

/\* Check if there was an error \*/
%put &SYSERRORTEXT ;

data Var_tab;
FORMAT varerror best8.;

proc sql ;

SELECT CASE WHEN "&SYSERRORTEXT" = "" THEN varerror = 1 ELSE varerror = 0 END AS VAR8
into :varerror
from WORK.Var_tab ;quit;


I want a variable telling me if the SYSERRORTEXT is blank or not.


Solution

  • I think you would be better off using SYSCC instead of SYSERRORTEXT.

    8         %let syscc=0;
    49         %put NOTE: &=syscc &=syserrortext;
    NOTE: SYSCC=0 SYSERRORTEXT=
    50         
    51         bad;
               ___
               180
    
    ERROR 180-322: Statement is not valid or it is used out of proper order.
    
    52         %put NOTE: &=syscc &=syserrortext;
    NOTE: SYSCC=3000 SYSERRORTEXT=180-322: Statement is not valid or it is used out of proper order.
    53         
    54         %if &syscc GT 0 %then %do;
    55            %let flag=1;
    56            %end;
    57         %else %do;
    58            %let flag=0;
    59            %end;
    60         
    61         %put NOTE: &=flag;
    NOTE: FLAG=1