标题: 求助高人:样本间隔的统计 [打印本页] 作者: shiyiming 时间: 2009-3-22 00:07 标题: 求助高人:样本间隔的统计 求助高人:样本间隔的统计
下列程序是想统计1出现时,距上次出现间隔了多少次,怎么不对,请高手帮助?
data aa;
input x @@;
cards;
1 2 1 1 2 2 1 1 1 1 2 2 2 2 1 2 2 1 2 2 2 1
;
run;
data aa1;
set aa;
if x=1 then x_1+1; else x_1=.;
if x^=1 then x_2+1; else x_2=.;
if x=1 and x^=lag(x) then x_1jg=lag(x_2);
if x=1 and x =lag(x) then x_1jg=0;
if x=2 and x^=lag(x) then x_2jg=lag(x_1);
if x=2 and x =lag(x) then x_2jg=0;
run;
谢谢!!作者: shiyiming 时间: 2009-3-23 16:18 标题: Re: 求助高人:样本间隔的统计 data t;
set aa;
retain sum 0;
if x = 1 then
sum = 0;
else sum + 1;
run;作者: shiyiming 时间: 2009-3-23 21:11 标题: Re: 求助高人:样本间隔的统计 谢谢指教!! 好象不对?