作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图找到一种方法来只打印 SAS 数据集的前 10 个和最后 10 个观察值。有没有办法做到这一点?
我试过 proc print data = ia.usage; where Obs < 10 & Obs > 80;run;
但该命令仍会打印出所有 90 个观察值。关于如何轻松做到这一点的任何想法?
谢谢。
最佳答案
获得前 10 个很容易:
/*First 10 obs*/
proc print data = ia.usage(obs = 10); run;
/*Last 10 obs*/
data last10 /view = last10;
startobs = nobs - 9;
set ia.usage nobs = nobs firstobs = startobs;
drop startobs;
run;
proc print data = last10; run;
data first10 /view = first10;
set ia.usage(obs = 10);
run;
data first10_last10 /view = first10_last10;
set first10 last10;
run;
proc print data = first10_last10; run;
data first10_last10 /view = first10_last10;
do nobs = 1 by 1 until(eof);
set ia.usage(drop = _all_) end = eof; /*We only want the row count, so drop all vars on this pass to save a bit of time*/
end;
do _n_ = 1 to nobs;
set ia.usage;
if _n_ <= 10 or _n_ >= nobs - 9 then output;
end;
run;
proc print data = first10_last10;
关于sas - 如何在SAS中打印前10个和最后10个观察值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46264967/
我是一名优秀的程序员,十分优秀!