全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2850 11
2010-07-22
有这么一组数据,
customer_nocard_no
100002
100003
100006
100008
200005
200012
300015
400020

我现在要分别汇总customer_no=1、2、3、4客户所拥有的卡数,请问该怎么做?
附:我用if first.customer_no then cardsum=0; cardsum=cardsum+1;的做法显示说我未初始化first.customer_no.
然后我就用proc sql来做,这是我的代码
proc sql;
create table count as
select count(distinct customer_no) as customer
  from a1
  ;
  quit;
但还是做不出正确答案。
二维码

扫码加我 拉你入群

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

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

全部回复
2010-7-22 12:04:50
proc sql;
create table count as
select count(distinct customer_no) as customer
  from a1
group by customer_no
  ;
  quit;
二维码

扫码加我 拉你入群

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

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

2010-7-22 12:05:09
data wkn;
input customer_no $ card_no$;
cards;
1 00002
1 00003
1 00006
1 00008
2 00005
2 00012
3 00015
4 00020
;
run;
proc sql;
create table wkn1 as
select customer_no,count(*) as cardsum
from wkn
group by customer_no;
quit;
试试看
二维码

扫码加我 拉你入群

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

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

2010-7-22 12:10:37
2# pobel
哈哈。我猜,结果都是1吧。
二维码

扫码加我 拉你入群

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

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

2010-7-22 12:24:13
jingju11 发表于 2010-7-22 12:10
2# pobel
哈哈。我猜,结果都是1吧。
马虎了

proc sql;
create table count as
select distinct customer_no ,   count(distinct card_no) as cardnum
  from a1
group by customer_no
  ;
  quit;
二维码

扫码加我 拉你入群

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

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

2010-7-22 12:46:25
那我第一种方法可否做的出来?
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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