我有以下数据。
acct seq start end
1111 A 01/01/2014 01/31/2014
1111 A 02/01/2014 02/28/2014我需要排除帐户的开始日期是结束日期后1天的记录。因此,上述记录将被排除,因为它在第一次观测中的结束日期为2014年1月31日,在随后的观测中的开始日期为2014年2月1日。
我想我需要使用Retain来完成这项工作,但我不太确定如何编写它。任何帮助都将不胜感激。
发布于 2014-05-14 21:20:08
Proc SQL解决方案...假设您使用的是SAS日期...
proc sql;
create table excludes as
select distinct acct
from data as one
left join data as two
on one.acct=two.acct and one.end=two.start-1
where two.start is not null;
create table filtered as
select *
from data
where acct not in
(
select *
from excludes
);
quit;https://stackoverflow.com/questions/23655756
复制相似问题