全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3815 10
2011-04-12
要求如题,比如有一列数据:

122.101715

777

67.296753

514.296936

11.906313

669.19519

16.6015

1471.5

19.2969

48.406376

744.898438

58.398251

64.601601

265.000153

84.296753

606.203125

461.898438

566.601563

34.796963

790.398438

54.5

56.406311

386.499939

887.5

45

1638.000122

468

28.093687

606.703003

69.203316

97.59375

73.499878

87.406372

38.898289

要求筛选出小于100的数据,且如果小于100的数据有两个以上是连续在一起的话,视作一组,(意思就是小于100的数据连在一起的有2个以上的作为一组,组的分界线就是它上下的大于100的数据,这样的作为一组),做出来的目的就是想求出总的组数,和各组间数据的总数(计数)!谢谢各位大侠   
求sas计算程序!!!
二维码

扫码加我 拉你入群

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

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

全部回复
2011-4-19 12:16:38
1# jpingl1273

data l;
input x@@;
if x<100 then count=1;
else; if x>=100 then count=.;
datalines;
73.499878
87.406372
38.898289
163.500153
100.398247
207.5
168.703308
29.898287
963.000122
45.898289
185.601715
972.999878
9.8984
15.203313
42.695187
834.999939
216.500061
444.703247
20.601563
79.093628
273
273.000061
396.906311
406.296722
49.796963
75.601501
;
run;
 
data need (keep=subtotal);
set l;
by count notsorted;
if first.count then do;
               subtotal=
0;
               group=
0; end;
           group+
1;
           subtotal+x;
if first.count and last.count then delete;
if last.count and count ne .;
run;
二维码

扫码加我 拉你入群

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

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

2011-4-19 21:34:07
呵呵 谢谢你的回复
我最终要的是符合条件的组数以及这些组一共有多少个数据(要的是个数),最总其实要的是总的个数除以组数 2# sas_user
二维码

扫码加我 拉你入群

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

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

2011-4-20 02:17:39
3# jpingl1273
以下是改过的,再试一下?如果不对,我再改。

 
data need ;
set l end=end;
by count notsorted;
if first.count then do; subtotal=0; group+1; end;
subtotal+x;
if first.count and last.count then delete;
if count = . then delete;
drop count;
run;


proc sql;
select count(x)/(count (distinct group)) as result from need;
quit;
二维码

扫码加我 拉你入群

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

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

2011-4-20 10:23:05
data l;
input x@@;
datalines;
73.499878
87.406372
38.898289
163.500153
100.398247
207.5
168.703308
29.898287
963.000122
45.898289
185.601715
972.999878
9.8984
15.203313
42.695187
834.999939
216.500061
444.703247
20.601563
79.093628
273
273.000061
396.906311
406.296722
49.796963
75.601501
;
run;
data n;
set l;
if x<100 then count=1;
else  count=.;
if  count then temp+count;
else temp=0;
if  temp>=3 then do;
     total_group+1;
  total_num+temp;
end;

proc sql;
create table numb as
select max(total_group) as t_group,
        max(total_num)   as t_num,
        max(total_num)/max(total_group) as ratio
  from  n;
二维码

扫码加我 拉你入群

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

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

2011-4-20 11:26:51
3# jpingl1273

"最总其实要的是总的个数除以组数"
总的个数是不是指小于100的连在一起的数字的个数?组数是不是指小于100的连在一起的数字共有多少组?请楼主确认是不是我理解错了?总个数除以组数是不是10/4呢?
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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