Sas 宏发送邮件

Sas macro send email

您好,我正在尝试使用宏从 sas EG 发送邮件。请问我有两个问题:

  1. 此代码生成错误:“没有匹配的 %DO 语句 来自 %END。该语句将忽略“
  2. 如何更改 HTML 输出样式?

    %macro desicion;
       %if &dsempty=0 %then %do
          filename outbox email
          to=('smdy@mail.com')
    
          type='text/html'
          subject='Achtung!'
          from=('Robot@sender');
    
          ods html body=outbox rs=none;
    
          proc report data=work.final1 style=Analisis;
          run;
    
          ods html close;    
       %end;
    %mend;
    

1) 你忘记了 %do

之后的 ;
%macro desicion;
%if &dsempty=0 %then %do;
               filename outbox email
               to=('smdy@mail.com')

               type='text/html'
               subject='Achtung!'
               from=('Robot@sender');

      ods html body=outbox rs=none;

      proc report data=work.final1 style=Analisis;
      run;

      ods html close;

%end;
%mend;

2) 这个问题有点宽泛

您可以应用模板样式,但这并不总能提供所需的结果。
我所做的是构建一个完整的 html 电子邮件,其中集成了 css 像这样

    data _null_;
        file mymail;
        set DS end=eof;

        if _n_=1 then do;
            put '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
            put '<html xmlns="http://www.w3.org/1999/xhtml">';
            put '<head>';
            put '  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
            put '  <title>TITLE</title>';
            put '  <style type="text/css">';
            put '    .row{width:100%;} ';
            put '    body {margin:0; padding:0;} ';
            ...

编辑:link 对此方法有更多解释(参见第 3 页)
http://support.sas.com/resources/papers/proceedings10/060-2010.pdf