data temp(keep=x);
call streaminit(133);
do
i=1 to 1000;
x= ceil(rand('UNIFORM')*6);
output;
end;
run;
--------------------------------------------------------------
data out56(keep=NumRolls);
set temp;
retain count;
retain NumRolls(0);
if count =2
then NumRolls =0;
if x=5
then count=1;
else if (x=6 and count=1)
then count=count+1;
else count=0;
NumRolls=NumRolls+1;
if count=2;
output;
run;
-------------------------------------------------------------
proc print data=out56;
run;作者: shiyiming 时间: 2008-9-28 13:09 标题: Re: 求助:一个SAS作业不会做,求各位帮帮忙 [code:3tj60ltl]data dice;
drop i; call streaminit(86);
do i =1 to 10000; x = ceil(rand('UNIFORM')*6);
output;
end;
run;
data aa;
set dice;
if x in (5,6) then fig=1;
else fig=0;
fig=lag(fig);
run;
data aa;
set aa;
retain sign 0;
if x=6 and fig=1 then sign=_n_;
sign1=lag(sign);
run;
data bb;
set aa;
by sign;
if first.sign then num=sign-sign1;
run;