我有一个数据集,其中包含我想为宏中的数据集定义的变量的名称和属性。例如:
variable_name = "filedate"
variable_length = 8
variable_label = "Date file was loaded"
variable_format = "date9."
variable_derivation = "filedate = today()"
宏做的是这样的:
%macro create_ds;
data _null_;
set variable_definitions;
call symputx('varname', variable_name);
call symputx('varlength', variable_length);
call symputx('varlabel', variable_label);
call symputx('varformat', variable_format);
call symputx('varderive', variable_definition);
run;
data newds;
attrib &varname length=&varlength label="&varlabel" format=&varformat;
&varderive;
run;
%mend create_ds;
我希望datastep看起来像是:
data newds;
attrib filedate length=8 label="Date file was loaded" format=date9.;
filedate = today();
run;
我实际得到的是:
data newds;
attrib filedate length=8 label="Date file was loaded" format=date9.;
.;
run;
然后抛出错误,因为“。”不是有效的陈述。
有没有办法将一个datastep语句分配给一个宏变量并实际让它执行?