sas - SAS按组识别单品未按预期工作
问题描述
我正在尝试从某个组中删除汗衫。这是我的代码:
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;
这将删除任何“唯一”记录。
推荐阅读
- css - 为什么溢出-y 没有按预期工作
- xamarin.forms - 删除对话框导航棱镜表格
- java - 如何将 int 传递给另一个活动以在 Android Studio 中进行计算?
- django - 在没有 Javascript 和验证的情况下使用 POST 向表单集添加附加表单
- java - 在终端中使用外部 jar 文件编译 java
- python - 如何在列表中获得减量?
- r - 按因子排序箱线图(iris,R,ggplot)
- python-3.x - 将带有自定义节点对象的图形写入 Networkx 中的 gml 文件
- javascript - 为 HTML5 视频添加字幕
- git - 如何更改 git global user.email?