根据条件发送电子邮件 (SAS)

SEND EMAIL BASED ON CONDITIONS (SAS)

我在这个论坛中找到了以下代码(未修改),它与我正在寻找的代码非常接近,但是在调整时遇到了一些问题;

data Millenium_Falcon;
han='1';
luke='0';
darth='0';
run;

filename myemail EMAIL
to="me@lando.com"
cc="me@lando.com"
from="me@lando.com"
subject="Millenium Falcon"
importance="HIGH"
;

data _null_;
set Millenium_Falcon ;
file myemail;
IF (Luke = '1' and Darth = '0') then do;
    put "Han,";
    put " ";
    put "Look out for the asteroids.";
    put " ";
    put "Thank you.";
    put " ";
    put "Obi";
end;
else do;
    put '!EM_ABORT!';
end;
stop;
run;

在调整之前,这段代码工作正常,但是当我尝试指向我的数据集(删除上面的 Millennium_Falcon 步骤)时,它只包含来自 dictionary.tables 的元数据(libname、memname、modate)并将 if 语句更改为

IF (memname = 'TEST' and datepart(modate) = date()) then do; 

邮件没有发送。这几乎就像数据步骤(下面)必须存在(像数据线一样)才能工作。

data Millenium_Falcon;
han='1';
luke='0';
darth='0';
run;

如有任何帮助,我们将不胜感激。

非常感谢

亚伦

您可能想要更像这样的东西,它会在没有记录满足条件时中止,否则会生成符合条件的值列表。

data _null_;
  file myemail;
  if _n_=1 and eof then put '!EM_ABORT!';
  set have end=eof ;
  where (memname = 'TEST' and datepart(modate) = date()) ;
  put memname= modate= ;
run;