楼主: may3000
4219 14

SAS新手求助如何更新数据集中的变量 [推广有奖]

  • 3关注
  • 1粉丝

已卖:7份资源

硕士生

7%

还不是VIP/贵宾

-

威望
0
论坛币
41 个
通用积分
0
学术水平
0 点
热心指数
1 点
信用等级
0 点
经验
3824 点
帖子
48
精华
0
在线时间
209 小时
注册时间
2013-5-9
最后登录
2017-6-7

楼主
may3000 发表于 2014-3-23 11:47:11 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
例如现在又两个数据集
数据集 a
id name
1 qqq
2 www
3 rrr
2 vvv
1 jjj
数据集 b
id   name
1    @#
2    &……
3    *&


数据集B中的name是乱码,我想用数据集a中的name更新数据集b的name 且id相互匹配。

请教如何实现

二维码

扫码加我 拉你入群

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

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

关键词:新手求助 数据集 name 如何实现 如何

沙发
intheangel 学生认证  发表于 2014-3-23 12:06:11
data b;
merge b a;
by id;
方法很多,用update代替merge也可以,但是merge比较简单
我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

藤椅
may3000 发表于 2014-3-23 12:27:25
intheangel 发表于 2014-3-23 12:06
data b;
merge b a;
by id;
WARNING: Multiple lengths were specified for the variable name by input data set(s). This may cause truncation of data.
WARNING: The MASTER data set contains more than one observation for a BY group.
。。。。。
ERROR: BY variables are not properly sorted on data set MYDATA.CN00
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 6833 observations read from the data set MYDATA.IE_P_JAP.
NOTE: There were 59622 observations read from the data set MYDATA.CN00.
WARNING: The data set MYDATA.IE_P_JAP may be incomplete.  When this step was stopped there were 7472 observations and 120 variables.
WARNING: Data set MYDATA.IE_P_JAP was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.25 seconds
      cpu time            0.21 seconds
失败。。难道是因为数据集格式不一样不能merge吗,求教

板凳
intheangel 学生认证  发表于 2014-3-23 12:39:26
may3000 发表于 2014-3-23 12:27
WARNING: Multiple lengths were specified for the variable name by input data set(s). This may caus ...
你b中的name是numeric还是character?
我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

报纸
may3000 发表于 2014-3-23 13:07:47
intheangel 发表于 2014-3-23 12:39
你b中的name是numeric还是character?
b中的是$32.
a中的是$200.

地板
may3000 发表于 2014-3-23 13:10:15
intheangel 发表于 2014-3-23 12:39
你b中的name是numeric还是character?
而且我直线更新name,这样会不会把其他的变量也改变了?

7
intheangel 学生认证  发表于 2014-3-23 14:12:44
may3000 发表于 2014-3-23 13:07
b中的是$32.
a中的是$200.
长度不同应该是可以merge的啊,不影响
我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

8
intheangel 学生认证  发表于 2014-3-23 14:20:18
may3000 发表于 2014-3-23 13:10
而且我直线更新name,这样会不会把其他的变量也改变了?
只会该variable名一样的,比如你name都有,就会覆盖了,如果一个是name1另一个是name2,就会合并成两列
我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

9
intheangel 学生认证  发表于 2014-3-23 14:21:40
may3000 发表于 2014-3-23 12:27
WARNING: Multiple lengths were specified for the variable name by input data set(s). This may caus ...
你error的原因是因为你a里面的id没有排序,那么是不能merge的

你merge前要把两个数据集都按照id排序;
proc sort data=..;
by id;
然后才能merge
我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

10
may3000 发表于 2014-3-23 17:34:09
intheangel 发表于 2014-3-23 14:21
你error的原因是因为你a里面的id没有排序,那么是不能merge的

你merge前要把两个数据集都按照id排序; ...
好的我再试试 多谢

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

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