SAS中文论坛

标题: 计算前九位的数据,剩下的求和计为其他怎么做? [打印本页]

作者: shiyiming    时间: 2013-7-9 18:40
标题: 计算前九位的数据,剩下的求和计为其他怎么做?
我需要统计前九的数据,其余数据求和,怎么做?
举例:
i
1
2
3
4
5
6
7
8
9
10
11
12
我要得到
1
2
3
4
5
6
7
8
9
33

[code:2fp4qiu7]data freq ;
  do i=1 to 12;
    output;
  end;
run;
data Top10;
set freq end=last;
if _N_<=9 then COUNT=i;
if _N_>9 then COUNT+i;
if         _N_<=9 then output;
if last then output;
run;[/code:2fp4qiu7]
作者: shiyiming    时间: 2013-8-30 15:45
标题: Re: 计算前九位的数据,剩下的求和计为其他怎么做?
[code:34o2kgqe]data ex ex2;
   do a=1 to 12;
     output;
   end;
run;
data ex2(drop=count);
  set ex(firstobs=10) end=last;
  if _N_>=1 then do;
   count+a;
   end;
   a=count;
if last then output;
run;
data ex3;
   set ex(obs=9) ex2;
run;[/code:34o2kgqe]




欢迎光临 SAS中文论坛 (http://www.mysas.net/forum/) Powered by Discuz! X3.2