本文主要是介绍数学之路-sas备忘(10),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
merge合并2个或2个以上的数据集。
libname saslib "k:\sas";
data saslib.goodsprice;
input id name$ price 6.2;
datalines;
1 鼠标 35.6
2 键盘 28.95
3 鼠标垫 8.2
4 耳麦 29.7
;
data saslib.goodsquantity;
input id quantity;
datalines;
1 150
2 98
4 162
3 45
;
proc sort data=saslib.goodsprice;
by id;
proc sort data=saslib.goodsquantity;
by id;
data saslib.mygoods;
merge saslib.goodspricesaslib.goodsquantity;
by id;
run;
proc print data= saslib.mygoods;
run;
本博客所有内容是原创,如果转载请注明来源
http://blog.csdn.net/myhaspl/
也可使用update,但update仅能操作2个数据集。
libname saslib "k:\sas";
data saslib.goodsprice;
input id name$ price 6.2;
datalines;
1 鼠标 35.6
2 键盘 28.95
3 鼠标垫 8.2
4 耳麦 29.7
;
data saslib.goodsquantity;
input id quantity;
datalines;
1 150
2 98
4 162
3 45
;
proc sort data=saslib.goodsprice;
by id;
proc sort data=saslib.goodsquantity;
by id;
data saslib.mygoods;
update saslib.goodspricesaslib.goodsquantity;
by id;
run;
proc print data= saslib.mygoods;
title '电脑周边产品';
run;
libname saslib "k:\src\sas";
data saslib.goodsprice;
input id name$ price 6.2;
datalines;
1 鼠标 35.6
2 键盘 28.95
3 鼠标垫 8.2
4 耳麦 29.7
;
data saslib.goodsquantity;
input id quantity;
datalines;
1 150
2 98
4 162
3 45
;
proc sort data=saslib.goodsprice;
by id;
proc sort data=saslib.goodsquantity;
by id;
data saslib.mygoods;
update saslib.goodspricesaslib.goodsquantity;
by id;
run;
proc print data= saslib.mygoods;
title '电脑周边产品';
run;
这篇关于数学之路-sas备忘(10)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!