【发布时间】:2019-04-29 10:54:44
【问题描述】:
我需要在我的数据步骤中循环一些宏变量 我试图定义宏变量并动态构建它们 像这样的数据步骤
DATA _NULL_;
call symputx('_rbank_1',put(001,z3.));
call symputx('_rwebhost_1','company1.myhost.com');
call symputx('_rbank_2',put(008,z3.));
call symputx('_rwebhost_2','company2.myhost.com');
call symputx('_rbank_3',put(008,z3.));
call symputx('_rwebhost_3','company3.myhost.com');
RUN;
%let _rbank_1 = &_rbank_1;
%let _rwebhost_1 = &_rwebhost_1;
%let _rbank_2 = &_rbank_2;
%let _rwebhost_2 = &_rwebhost_2;
%let _rbank_3 = &_rbank_3;
%let _rwebhost_3 = &_rwebhost_3;
data test;
do cnt=1 to 3;
macroString=compress("&_rwebhost_"||cnt);
marcroValue=macroString;
end;
run;
但是 macroValue 的输出是“&_rwebhost_3”,我需要它 成为价值而不是名称。
我可以在宏中执行此操作,但我在数据步骤中确实需要它。 通常在其他编程语言中我会定义一个哈希表 但这在 sas datastep 中似乎并不那么简单。
【问题讨论】: