全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1581 3
2014-07-24
DN_~}T%D)XR@H%PE$P1O2_6.jpg 如图是一些data type的数据,我想实现count按照不同的data type进行累加,分别得到critical、non-critical、 half-critical的累加起来的count。
求大神指教!!!!!
二维码

扫码加我 拉你入群

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

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

全部回复
2014-7-24 22:59:54
data have;
input type $14. count;
datalines;
critical      1
critical      2
non-critical  3
half-critical 4
half-critical 5
half-critical 6
non-critical  7
non-critical  8
critical      9
critical      10
half-critical 11
half-critical 12
;
run;

/****method 1:SQL****/
proc sql;
create table want as
select distinct type,
       sum(count) as total
from have
group by 1
order by 2
;
quit;

/***method 2:data step****/

proc sort data=have;
by type;
run;

data want2 /*(drop=count)*/;
set have;
by type;
total+count;
if first.type then total=count;
*if last.type;
run;


both methods have their pros and cons
二维码

扫码加我 拉你入群

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

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

2014-7-25 10:09:56
tangliang0905 发表于 2014-7-24 22:59
data have;
input type $14. count;
datalines;
是这样的,其实critical,non-critical不是data_type的值,只是一个format,值是不一样的。我想按照这种format来分类累加
二维码

扫码加我 拉你入群

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

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

2014-7-25 22:46:16
I don't think the formats matter. You can still go ahead and try it.
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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