%macro nlp(start,end,increment);
%let i = &start.;/*定义宏变量*/
%do %while (&i.<= &end.);/*定义循环体*/
data quad1;
set quad;
if _type_ ="ge" then _rhs_ = &i.;/*修改期望值*/
proc nlp inquad=quad1 outest=nlp_out6 noprint;/*求最优组合*/
min;
parms x1-x8;
run;
data function;/*提取期望和相应风险值*/
ge=&i.;
set nlp_out6(where=( _type_ = 'PARMS'));
keep ge _RHS_;
run;
%if &i. = &start. %then %do;/*数据初始化*/
data base;set function;run;
%end;
%else %do;/*追加数据集*/
proc append base =base data=function force;
run;
%end;
%let i=%eval(&i.+ &increment.);/*自动增加变量*/
%end;
%mend nlp;
%nlp(0.008,0.026,0.002);
run;
----------------------------
大侠你好,这是我根据你的思路做的宏,但运行之后只得出一个结果。然后就是错误提示:
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
operand is required. The condition was: 0.008+ 0.002
ERROR: The macro NLP will stop executing.--
怎么会是操作符不对呢??