How to merge with duplicate observation on both sides

  • Follow


Hi,

If I have two files like this:

Left.csv:
ID  Value1
1    a
1    b

Right.csv
ID  Value2
1   c
1   d

Note the ID is duplicate. I want to merge by ID (most other
observations that not duplicate like this pathological example) but
how do I merge the two files so that every possible combination of
values are present in the merged file

Desired output:
Merge.csv
ID   Value1 Value2
1       a         c
1       a         d
1       b         c
1       b         d
0
Reply hewei2004 (3) 3/21/2010 10:51:58 PM

Use SQL to get a FULL JOIN.
proc sql;
 create table new as
    select a.*,b.*
    from left a full join right b
    on a.id =3D b.id
 ;
quit;

On Mar 21, 6:51=A0pm, hewei2004 <hewei2...@gmail.com> wrote:
> Hi,
>
> If I have two files like this:
>
> Left.csv:
> ID =A0Value1
> 1 =A0 =A0a
> 1 =A0 =A0b
>
> Right.csv
> ID =A0Value2
> 1 =A0 c
> 1 =A0 d
>
> Note the ID is duplicate. I want to merge by ID (most other
> observations that not duplicate like this pathological example) but
> how do I merge the two files so that every possible combination of
> values are present in the merged file
>
> Desired output:
> Merge.csv
> ID =A0 Value1 Value2
> 1 =A0 =A0 =A0 a =A0 =A0 =A0 =A0 c
> 1 =A0 =A0 =A0 a =A0 =A0 =A0 =A0 d
> 1 =A0 =A0 =A0 b =A0 =A0 =A0 =A0 c
> 1 =A0 =A0 =A0 b =A0 =A0 =A0 =A0 d

0
Reply Tom 3/21/2010 10:58:01 PM


1 Replies
360 Views

(page loaded in 0.032 seconds)

Similiar Articles:













7/23/2012 5:33:26 PM


Reply: