proc sql;
select a.id as var1, b.id as var2
from test as a, test as b
where a.n2-b.n2=10
;quit;[/code:12gp2v55]作者: shiyiming 时间: 2011-1-27 12:53 标题: Re: 难题求解 不考虑ID了?作者: shiyiming 时间: 2011-1-28 05:10 标题: Re: 难题求解 to sxlion
All three methods above can be used to sovle this problem. However,
the first and third one are not good for the large data set because of
the limitation of computer memory. So the second one is the best - using
POINT option for direct access.
Unlike any other databases, the record pointer (not exist but you can
imagine) in SAS can not move forward or backward freely with your
control. I am still struggling on this problem. Once I have the solution,
I will share it with you guys for sure. We might consider the following
piece of sas code:
data test_1;
set test;
by ID;
retain pointer .;
if first.id=1 then pointer=_N_;
if not last.id then do;
pointer=pointer+1;
.
.
.
.
do j=pointer to last_positon_within_ID;
set test(rename=(time=time_1) keep=time) POINT=j;
if time_1-time=10 then do something;
end;
.
.
.
run;作者: shiyiming 时间: 2011-1-28 09:26 标题: Re: 难题求解 楼主做pharm或者health care的吧?数据有多大,SQL的 Cartesian product做不了?一定要用data step实现?Just curious.作者: shiyiming 时间: 2011-1-28 14:24 标题: Re: 难题求解 to 楼主, 你的那个solution不是正中data步的缺点吗?