sql - Variable number of parameters in macro in SAS? -


i have macro passing in 6 table names , 6 columns. however, number of columns , tables not constant.

is there way have variable number of parameters? familiar concept in python **kwargs.

also, there way parameterize proc sql statement take many col , table inputs provided? or try catch of sort in sas check if variables exist before running sql statement?

here macro i'm trying parameterize.

%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   select a1._name_, a1.&trans_col &col_1, a2.&trans_col &col_2,         a3.&trans_col &col_3, a4.&trans_col &col_4, a5.&trans_col &col_5,         a6.&trans_col &col_6  &tbl_1 a1, &tbl_2 a2, &tbl_3 a3, &tbl_4 a4, &tbl_5 a5,       &tbl_6 a6   a1._name_ = a2._name_ = a3._name_ = a4._name_ = a5._name_ = a6._name_;  run;  %mend generate_tp_table; 

pass them in single parameter , have macro parse them out later.

%macro (parameters = , table_list = tb1 tb2 tb3 ... tb6, col_list=col1 col2 ... col6, other_parms= ... ); 

i recommend building rest of code using loop number of parameters. documentation here has bad example of how extract each element of list:

http://support.sas.com/documentation/cdl/en/mcrolref/67912/html/default/viewer.htm#p1n2i0ewaj1zian1ria5579z1zjh.htm

the sql ugly...i wonder if data step easier since you're merging on single variable? becomes rename each table in example above in many respects.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -