2017-10-12 70 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行添加到您的數據步驟中。