2017-10-12 53 views
1

我试图通过在动态文本中使用%宏来动态显示电子邮件中的文本。这工作,但在我的电子邮件中添加了几行文字后,它停止工作。所以,我不确定是什么导致了实际问题。恢复到我工作时的位置不再有效。SAS - 通过%宏向电子邮件动态添加文本

我的宏我打电话:

%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; 

它的工作,现在没有,而且我不知道它如何能之前,现在已经工作过。任何建议将不胜感激!!!提前致谢!

+1

在数据步骤中,'put'写入'outmail'。另一方面'%PUT'写入日志。我无法测试它,但尝试用'put'替换宏中的'%put'。 – Petr

+0

@Petr非常感谢。这就是诀窍!如果你想继续写下这个答案,我会接受它! –

回答

1

Put在数据步骤中写入输出表/文件(例如outmail在你的例子中),%put在你的宏写入日志。尝试用put代替宏中的%put - 它会将这5行添加到您的数据步骤中。