我有一個宏,我正在傳遞6個表名和6列。但是,列和表的數量並不總是恆定的。SAS中宏的參數可變數量?
有沒有一種方法來有一個可變數量的參數?我用** kwargs熟悉python中的概念。
此外,有沒有一種方法來參數化proc sql語句只採取儘可能多的col和表輸入?或者在SAS中嘗試捕獲某種類型的變量以檢查在運行sql語句之前變量是否存在?
這是我想要參數化的宏。
%macro Generate_TP_tbl(new_tbl_name, trans_col, tbl_1, tbl_2, tbl_3, tbl_4,
tbl_5, tbl_6, col_1, col_2, col_3, col_4, col_5, col_6);
proc sql;
CREATE TABLE &new_tbl_name AS
SELECT a1._NAME_, a1.&trans_col as &col_1, a2.&trans_col as &col_2,
a3.&trans_col as &col_3, a4.&trans_col as &col_4, a5.&trans_col as &col_5,
a6.&trans_col as &col_6
FROM &tbl_1 as a1, &tbl_2 as a2, &tbl_3 as a3, &tbl_4 as a4, &tbl_5 as a5,
&tbl_6 as a6
WHERE a1._NAME_ = a2._NAME_ = a3._NAME_ = a4._NAME_ = a5._NAME_ = a6._NAME_;
run;
%mend Generate_TP_table;
在列表中使用空格而不是逗號。那麼你只需要一個或兩個參數。 – Tom