SAS - 通过 %macro 将文本动态添加到电子邮件

SAS - Dynamically adding text to an email via a %macro

我正在尝试通过使用 %macro 代替动态文本来动态显示电子邮件中的文本。这 工作,但在我的电子邮件中添加了几行额外的文本后,它停止工作了。所以,我不确定是什么导致了实际问题。恢复到我工作时的状态不再有效。

我正在调用的宏:

%macro PrintStuff(arrayOfThings);
    %local i next_element;
    %do i=1 %to %sysfunc(countw(&arrayOfThings));
        %let next_element = %scan(&arrayOfThings, &i);
        %DO;
            %PUT "&next_element info is as follows:";
            %PUT "some text here";
            %PUT "some text there";
            %PUT "text all over!!!";
            %PUT "Do you even text?";
        %END;
    %end;
%mend PrintStuff;

电子邮件代码:

DATA _null_;
    File mailFile;
    PUT "This is email text. This shows up fine in the email";
    %PrintStuff(&someArray);
    PUT "This closes the email, and this shows up fine in the email when it is received!"
RUN;

我在这里尝试了一些不同的东西。我试过在电子邮件中只包含 %PrintStuff(&myArrayOrList)。我试过使用和不使用结束 ; 分号。我不确定哪里出了问题。

代码运行成功后日志出现这样:

50         DATA _null_;
51          File outmail;
52          PUT "This is email text. This shows up fine in the email";
53         
54          %PrintStuff(&someArray)
"ResolvedElementName info is as follows:"
"some text here"
"some text there"
"some text all over!!!"
"Do you even text?"
55         
56          PUT "This closes the email, and this shows up fine in the email when it is received!";
57         RUN;

它起作用了,现在不起作用了,我不确定它以前是怎么起作用的。任何建议将不胜感激!!!提前致谢!

数据步骤中的

Put 写入输出 table/file(即您示例中的 outmail),宏中的 %put 写入日志。尝试用 put 替换宏中的 %put - 它会将这 5 行添加到您的数据步骤中。