SAS 按组识别单线态未按预期工作

SAS identifying singlets in by group not working as intended

我正在尝试从某个组中删除汗衫。这是我的代码:

proc sort data=have; by ID date; run;
 
data want; 
    set have;
    by ID date;
    if first.date and last.date then delete;
run;

对我来说,这应该删除同一 ID 中只有一个日期的所有条目。但出于某种原因,一个观察结果都没有通过。根据我的数据集,我应该显示数千个观察结果。我之前在其他数据集上使用过这个没有任何问题。我知道这不是很多事情要做,但我是否犯了一些错误,我错过了?

你在做什么:

data want; 
    set have;
    by ID date;
    if first.date and last.date then delete;   *if this is the first and last record for that date, then delete it;
run;

你想做什么,我相信:

data want; 
    set have;
    by ID date;
    if first.ID and last.ID then delete;  *if this is the only record for that ID then delete it;
run;

但是,这可能不是您想要的 - 取决于您的数据。你还有

proc sort nounikey data=have;
  by id;
run;

这将删除所有“唯一”记录。