|
|
沙发

楼主 |
发表于 2010-6-18 09:17:14
|
只看该作者
Re: 如何比较一维数据里的数
连着3个5,4个5,怎么办?
data step
[code:39wuk1i3]data temp;
input x;
id=_n_;
datalines;
2
3
5
5
8
9
;
data temp1(drop=x rename=(temp=x));
set temp(keep=x) end=last;
temp=lag(x);
if x=temp then i=1;
if _n_ gt 1 then output;
if last then do;
temp=x;
call missing(x,i);
output;
end;
run;[/code:39wuk1i3]
sql
[code:39wuk1i3]proc sql;
create table temp2 as
select a.x,case
when a.x=b.x then 1
else .
end as i
from temp a left join temp b
on a.id=b.id-1
order by a.id;
quit;[/code:39wuk1i3] |
|