SAS合并多个表 [英] SAS merging multiple tables

查看:43
本文介绍了SAS合并多个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道合并多个表的最佳方法是什么.我在所有表中都有一个唯一标识符.我应该在对表格进行排序后一步加入所有表格,还是应该逐一合并表格.这有关系吗?

I would like to know what is the best way to merge multiple tables. I have a unique identifiers across all the tables. Should I join all the tables in one step after sorting the tables OR should I should do stepwise one by one table merging. Does this matter ?

推荐答案

您可以在一个步骤中进行多个合并.然而,这并不是最安全的方式.如果您的数据可能存在缺陷,最好逐步执行此操作.恕我直言,最好在当时合并一个步骤,但这是你的决定.

You can do multiple merges at single step. However, this is not the safest way. If there is possibility that your data is subject to imperfections, it is best to do this step by step. Imho, it is best do merge a step at the time, but it's your call.

proc sort data=data1; by id; run;
proc sort data=data2; by id; run;
proc sort data=data3; by id; run;

data combo;
    merge data1(in=a) data2(in=b) data3(in=c); 
    by id; 
    if a and b and c; /*Inner join. Change as needed. */
run;

这相当于:

data partial;
    merge data1(in=a) data2(in=b);
    by id; 
    if a and b; 
run;

data combo;
    merge partial(in=a) data3(in=b);
    by id; 
    if a and b;
run,

这篇关于SAS合并多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆