1638 3

怎么实现分类累加 [推广有奖]

  • 0关注
  • 4粉丝

已卖:23份资源

教授

12%

还不是VIP/贵宾

-

威望
0
论坛币
6762 个
通用积分
19.5160
学术水平
18 点
热心指数
24 点
信用等级
15 点
经验
383 点
帖子
1182
精华
0
在线时间
997 小时
注册时间
2013-1-20
最后登录
2024-8-2

楼主
小宝爱波1314 发表于 2014-7-24 21:14:40 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
DN_~}T%D)XR@H%PE$P1O2_6.jpg 如图是一些data type的数据,我想实现count按照不同的data type进行累加,分别得到critical、non-critical、 half-critical的累加起来的count。
求大神指教!!!!!
二维码

扫码加我 拉你入群

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

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

关键词:Critical CRITIC Count crit type critical count

沙发
tangliang0905 发表于 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

藤椅
小宝爱波1314 发表于 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来分类累加

板凳
tangliang0905 发表于 2014-7-25 22:46:16
I don't think the formats matter. You can still go ahead and try it.

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 12:10