楼主: tjnkswordsman
2895 6

两组数据进行merge处理,为什么结果数据集观测数量反而比观测数最少的原数据集要多? [推广有奖]

  • 17关注
  • 7粉丝

教授

52%

还不是VIP/贵宾

-

威望
0
论坛币
373734 个
通用积分
0.2302
学术水平
0 点
热心指数
1 点
信用等级
0 点
经验
624 点
帖子
851
精华
0
在线时间
1983 小时
注册时间
2008-4-4
最后登录
2021-3-16

楼主
tjnkswordsman 发表于 2013-11-15 10:37:43 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
两组数据进行merge处理,为什么结果数据集观测数量反而比观测数最少的原数据集要多?
按照我的理解,结果数据集的观测数量应该等于观测数最少的原数据集。
求朋友们帮忙解释。
是否我的程序错误?
谢谢大家。

proc sort data=co_type  ;
by cocd;
run;
proc sort data=co_fail;
by cocd;
run;
data f_ty;
merge co_fail(in=a) co_type(in=b) ;
if a and b ;
by cocd;
run;

二维码

扫码加我 拉你入群

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

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

关键词:Merge 数据集 Data Fail type 朋友 程序

co_fail.xls
下载链接: https://bbs.pinggu.org/a-1438312.html

117 KB

原数据集1

co_type.xls

4.27 MB

原数据集2

回帖推荐

Imasasor 发表于2楼  查看完整内容

i know the problem. and no need to kan your chengxu. 其中一种可能,两个的cocd有缺失值,其中一个数据集有大于一个的缺失值 另一种可能,两个cocd中有重复值 如下面的code data a; input id a; cards; 1 3 2 4 2 5 4 2 ; data b; input id b; cards; 2 3 4 6 ; run; data c; merge a(in=x) b(in=y); by id; if x and y; run;

沙发
Imasasor 发表于 2013-11-15 10:50:21
i know the problem. and no need to kan your chengxu.
其中一种可能,两个的cocd有缺失值,其中一个数据集有大于一个的缺失值
另一种可能,两个cocd中有重复值
如下面的code
data a;
input id a;
cards;
1 3
2 4
2 5
4 2
;
data b;
input id b;
cards;
2 3
4 6
;
run;
data c;
merge a(in=x) b(in=y);
by id;
if x and y;
run;
欢迎加入亚太地区第一R&Python数据挖掘群: 251548215;

藤椅
tjnkswordsman 发表于 2013-11-15 10:58:10
Imasasor 发表于 2013-11-15 10:50
i know the problem. and no need to kan your chengxu.
其中一种可能,两个的cocd有缺失值,其中一个数据 ...
谢谢热心帮助,
我没有真正理解您的意思。
如何解决这种问题呢?

板凳
tjnkswordsman 发表于 2013-11-15 11:00:27
Imasasor 发表于 2013-11-15 10:50
i know the problem. and no need to kan your chengxu.
其中一种可能,两个的cocd有缺失值,其中一个数据 ...
情况应该是cocd有重复值,先去重再试试。
谢谢您指点

报纸
Imasasor 发表于 2013-11-15 11:01:13
tjnkswordsman 发表于 2013-11-15 10:58
谢谢热心帮助,
我没有真正理解您的意思。
如何解决这种问题呢?
说这么清楚了,例子也帮你写好了,再不理解就没办法了,你都当到副教授了
欢迎加入亚太地区第一R&Python数据挖掘群: 251548215;

地板
tjnkswordsman 发表于 2013-11-15 11:03:37
Imasasor 发表于 2013-11-15 11:01
说这么清楚了,例子也帮你写好了,再不理解就没办法了,你都当到副教授了
闻道有先后,术业有专攻,
虚心向您请教,
我run下您的例子看看。
谢了

7
tjnkswordsman 发表于 2013-11-15 11:05:50
Imasasor 发表于 2013-11-15 11:01
说这么清楚了,例子也帮你写好了,再不理解就没办法了,你都当到副教授了
已经理解了,

谢谢。

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

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