How to merge with duplicate observation on both sides

Discussion in 'SAS (Statistical Analysis Software)' started by hewei2004, Mar 21, 2010.

  1. hewei2004

    hewei2004 Guest

    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
     
    hewei2004, Mar 21, 2010
    #1
    1. Advertisements

  2. 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 = b.id
    ;
    quit;
     
    Tom Abernathy, Mar 21, 2010
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.