在 sas 中按行号选择特定行 [英] select specific rows by row number in sas

查看:123
本文介绍了在 sas 中按行号选择特定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 SAS 的新手我有 SAS 数据,例如(它不包含 Obs 列)

I am new to SAS I have SAS data like (It does not contain Obs column)

Obs    ID    Name    Score1    Score2    Score3

1     101               90        95        98
2     203               78        77        75
3     223               88        67        75
4     280               68        87        75
.
.
.
.
100   468               78        77        75

我想要行号为 2 6 8 10 34 的数据.输出应该是这样的

I want data having row number 2 6 8 10 34. Output should look like

Obs    ID    Name    Score1    Score2    Score3

1     203               78        77        75
2     227               88        67        75
3     280               68        87        75
.
.
.

提前致谢.

推荐答案

您可以使用一个数据步骤循环遍历每一行数据,并且仅在您处于第 n 个循环中且具有这样的条件时才输出这些行.

You can loop through each line of data with a data step and only output the lines when you are in the n'th loop with a condition like this.

data test;
    set LIB.TABLE;
    if _N_ in (2, 6, 8, 10, 34) then output;
    run;

其中 _N_ 将对应于这种情况下的行号.

where _N_ will correspond to the number of the line in this case.

这篇关于在 sas 中按行号选择特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆