全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2907 3
2010-08-18
语句是什么?

例如:input id vwm ewm r1-r10;
只想对前五十条数据或者后五十条记录进行分析

谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2010-8-18 10:11:03
找到了用if
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-8-21 10:47:38
ttracy_w 发表于 2010-8-18 09:52
语句是什么?

例如:input id vwm ewm r1-r10;
只想对前五十条数据或者后五十条记录进行分析

谢谢
There a couple ways for 前五十条数据.
1) use firstobs option of infile statement
2) construct a count and when count reaches 50 then stop

148  data t1;
149    infile 'C:\temp\test.txt' firstobs=3;
150    input;
151    cnt=1;
152    if cnt=3 then stop;
153  run;

NOTE: The infile 'C:\temp\test.txt' is:
      Filename=C:\temp\test.txt,
      RECFM=V,LRECL=256,File Size (bytes)=15,
      Last Modified=20Aug2010:22:42:08,
      Create Time=20Aug2010:22:42:08

NOTE: 3 records were read from the infile 'C:\temp\test.txt'.
      The minimum record length was 1.
      The maximum record length was 1.
NOTE: The data set WORK.T1 has 3 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


154
155  data t1;
156    infile 'C:\temp\test.txt' ;
157    input;
158    cnt+1;
159    if cnt=4 then stop;
160  run;

NOTE: The infile 'C:\temp\test.txt' is:
      Filename=C:\temp\test.txt,
      RECFM=V,LRECL=256,File Size (bytes)=15,
      Last Modified=20Aug2010:22:42:08,
      Create Time=20Aug2010:22:42:08

NOTE: 4 records were read from the infile 'C:\temp\test.txt'.
      The minimum record length was 1.
      The maximum record length was 1.
NOTE: The data set WORK.T1 has 3 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-8-21 11:42:35
ttracy_w 发表于 2010-8-18 09:52
语句是什么?

例如:input id vwm ewm r1-r10;
只想对前五十条数据或者后五十条记录进行分析

谢谢
lz,希望下面的程序能有所帮助,仅供参考:

data a;
input x @@;
cards;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
;
data b;
set a(firstobs=1 obs=5);/*取前5条记录*/
run;
data c;
set a(firstobs=16 obs=20);/*取后5条记录*/
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群