数据的更新或修改

举例学习update语句——资料来源http://support.sas.com/resources/

/**************************************************************/
/* Create pretend data.  DSD assumes the delimiter is a comma */
/* and strips the double quotes from the values with embedded */
/* delimiters.                                                */
/*                                                            */
/* A WARNING will be issued to the log due to the duplicates  */
/* found in master.                                           */
/**************************************************************/

data one;
  infile datalines dsd;
  input artist $ song :$30.;
datalines;
Abba,"Knowing Me, Knowing You"
Abba,I am the City
Abba,Mama Mia
Beatles,Blackbird
Beatles,Chains
Beatles,"Ob-La-Di, Ob-La-Da"
;

data two;
  infile datalines dsd;
  input artist $ song :$30. new;
datalines;
Abba,Waterloo,1
Beatles,Glad All Over,1
Beatles,Hey Jude,1
Doors,People Are Strange,1
;

data new;
   update one two;
   by artist;
run;
proc print;
run;

/*
Note:
Update uses observations from the transaction data set to change the values
of the corresponding observations from the master data set.
You must use a BY statement. Data needs to be in sorted order, or indexed.

Update works with two data sets only.

Note that if the master data set contains duplicates of the BY variable,
the first observation is updated and the remaining observations are ignored.

If the transaction data set contains duplicates, all values overlay
the first match in master.

If your goal is to update all the observations in master,
consider using MERGE instead.

*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值