[英]how to create a macro from variable length function? where macro value is another variable length function
[英]How to create a SAS macro variable name from another macro variable and a string?
假設我有一個名為var1
和var1_test
的數據集。 我正在使用輸入var1
編寫宏。 現在,我正在尋找一種從var1
和字符串"_test"
var1_test
"_test"
創建var1_test
的方法。 最終,我想在where條件中使用此變量。 我嘗試了以下方法:
%macro some_name(var =);
%let var2 = %sysfunc(catx(&var., '_test'));
proc sql;
select ...
from ...
where &var2. = 1;
quit;
%mend;
您無需將cat
函數與宏語言中的宏變量一起使用。 它們只是打開的文本,因此只要在它們旁邊放置更多文本即可自動串聯。
%let var2 = &var._test;
您還使用了錯誤的CAT函數, catx
用於在中間放置定界符,因此第一個參數是定界符(因此它不會連接任何東西,因為它只看到一個要連接的東西)。 在參數周圍還會有引號,在%sysfunc
這是不正確的-在該上下文中,引號被視為實際字符,而不是字符串定界符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.