SAS merging multiple tables

后端 未结 2 1435
感情败类
感情败类 2021-01-29 00:30

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

2条回答
  •  醉酒成梦
    2021-01-29 01:08

    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;
    

    This is equivalent to:

    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,
    

提交回复
热议问题