|
楼主

楼主 |
发表于 2010-12-12 08:32:20
|
只看该作者
紧急求助::宏变量赋值不成功,请高手给改正下,谢谢
%macro nlp (start=,end=,step=,v1=,v2=,v3=,umean=,out=);
[color=#FF0000:2lxjhynl]%let w1=&v1.;
%let w2=&v2.;;
%let w3=&v3.;
%let u=&umean.;[/color:2lxjhynl]
%let i=&start.;
%do %while(&i.<=&end.);
proc nlp out=_sheet;
max y;
PARMS b;
bounds 0<=b<=1;
Y1= exp(w1);
Y2= exp(w2);
Y3= exp(w3);
sigma=&i.;
P1=1-probnorm((w1-u)/sigma); /*change the w1 into the N(0,1)distribution*/
P2=1-probnorm((w2-u)/sigma); /*here, we use the sigma vale,that is, 1-PDF*/
P3=1-probnorm((w3-u)/sigma);
y=P1*log(b*Y1+(1-b))+P2*log(b*Y2+(1-b))+P3*log(b*Y3+(1-b)); /*the objective is to achive the max y*/
run;
data temp1;
set _sheet;
sigma=&i.;
keep sigma b y y1 y2 y3 p1 p2 p3;
run;
%if &i. = &start. %then %do;/*initialize the date*/
data &out;
set temp1;
run;
%end;
%else %do;
data &out;
set &out temp1; /*append more date to result*/
run;
%end;
%let i=%sysfunc(sum(&i.,&step.));
%end;
%mend nlp;
%nlp (start=0.05,end=20, step=0.5,v1=0.2,v2=0.5,v3=1,umean=0,out=result)
我在运行的时候,总是报错:
[b:2lxjhynl]ERROR: The variable w1 was referenced but not given a value.
ERROR: The variable w2 was referenced but not given a value.
ERROR: The variable w3 was referenced but not given a value.
ERROR: The variable u was referenced but not given a value.
WARNING: Your program statements contain 4 symbols used but not given a value.[/b:2lxjhynl]NOTE: Initial value of parameter b is set randomly to 0.1148952079.
[b:2lxjhynl][color=#0000FF:2lxjhynl]ERROR: There are references to missing variables when the program code is executed for _OBS_= 1[/color:2lxjhynl][/b:2lxjhynl]请大家给诊断下,为啥 i=&start. 就能成功, 而这4个就不成呢,迷惑中。 |
|