proc printto log=_null_; run;
data data.ab;
a=-0.618;
b=1.618;
v=1+a*a;
u=1+(1-a)**2;
t=1+b*b;
s=1+(b-1)**2;
la=2*log(v/u);
lb=2*log(t/s);
c=la/log(1+a*a);
d=lb/log(1+b*b);
keep c d;
run;
proc fcmp outlib=sasuser.funcs.math_stat;
# not clear to me how it works
function lstar(u,c,d);
if (u le -0.618) then return (c*log(1+u*u));
if (u ge 1.618) then return (d*log(1+u*u));
else return(2*log((1+u*u)/(1+(u-1)*(u-1))));
endsub;
function g(u);
if (u le -0.25) then return (2*log((1+0.25*0.25)/(1+1.25*1.25)));
if (u ge 1.25) then return (2*log((1+1.25*1.25)/(1+0.25*0.25)));
else return(2*log((1+u*u)/(1+(u-1)*(u-1))));
endsub;
run;
options cmplib =sasuser.funcs;
%let r =10000;
data data.lstar;
call streaminit(1234); # for reproduce results
set ab;
do sample =1 to &r;
call missing(sum1, sum2);
do i =1 to 2000;
x =rand('T',3) ;
y =x/sqrt(3) ;
lstar =lstar(y,c,d) ;
l =g(y) ;
sum1 ++lstar; sum2 ++l;
if (sum1 lt 0) then sum1=0;
if (sum2 lt 0) then sum2=0;
output;
end;
end;
keep sample i sum1 sum2;
run;
data shifts_drifts;
set data.lstar;
by sample;
array _n[10] _temporary_ (1 2 3 4 5 6 7 8 9 10);
array _s[10] _temporary_; array _d[10] _temporary_;
if first.sample then call missing(of _s
do k =1 to dim(_n);
if _s[k] <1 then if (sum1 ge (2.01+0.01*(_n[k]-1))) then do;
_s[k] =1; n =_n[k]; cat ='shifts';
output shifts_drifts(keep =sample n i cat);
end;
if _d[k] <1 then if (sum2 ge (2.01+0.01*(_n[k]-1))) then do;
_d[k] =1; n =_n[k]; cat ='drifts';
output shifts_drifts(keep =sample n i cat);
end;
end;
run;
proc means data=shifts_drifts;
class n cat;
var i;
output out=ci_shifts_drifts(drop =_freq_ _type_) mean=ARL_sARL;
run;
上面的程序出现错误,SAS运行后出现下面结果,求帮忙
309 do k =1 to dim(_n);
310
311 if _s[k] <1 then if (sum1 ge (2.01+0.01*(_n[k]-1))) then do;
312 _s[k] =1; n =_n[k]; cat ='shifts';
313 output shifts_drifts(keep =sample n i cat);
-
22
76
ERROR 22-322: 语法错误,期望下列之一: 名称, 带引号的字符串, ;, RC, _DATA_, _LAST_, _NULL_.
ERROR 76-322: 语法错误,语句将被忽略。
314 end;