<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Many to many merge in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47953#M12933</link>
    <description>With multiple observations for a unique BY variable set, you will need to use some SAS procedure (MEANS, SUMMARY, UNIVARIATE) to generate a reduced observation set before using a DATA step MERGE process.&lt;BR /&gt;
&lt;BR /&gt;
Suggest you start out with getting your data into SAS members using a SAS DATA step, then explore what "data summarization or analysis" procedure will work for you, and then review the DATA step process for merging using a BY statement, so you can perform your calculation.&lt;BR /&gt;
&lt;BR /&gt;
I encourage you to use the DOC and technical paper references cited previously.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Thu, 18 Sep 2008 13:47:25 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2008-09-18T13:47:25Z</dc:date>
    <item>
      <title>Many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47950#M12930</link>
      <description>Urgent request.&lt;BR /&gt;
&lt;BR /&gt;
Can anybody help me with many to many merge? &lt;BR /&gt;
I have two datasets A and B, each has six variables (5 explanatory variables: agegroups, sex, service type, service group, and year) and one outcome variable (hospital admissions rate).  I want to calculate age-sex-service type-service group-year specific rate ratio but don't know how to merge these two files together as there is no unique matching ID and two files have difference number of rows.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 18 Sep 2008 13:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47950#M12930</guid>
      <dc:creator>Paris</dc:creator>
      <dc:date>2008-09-18T13:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47951#M12931</link>
      <description>Provide data sample(s) and the desired result, in your post, for a more effective and timely response to your question.  Also, to accomplish a MERGE in SAS, there are some data input requirements, depending on the desired results.  &lt;BR /&gt;
&lt;BR /&gt;
Below, you will find links to some SAS support website &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt; technical paper references for you to consider and review.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi27/p052-27.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi27/p052-27.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi25/25/cc/25p109.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi25/25/cc/25p109.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Reading, Combining, and Modifying SAS Data Sets - SAS DOC with subsections to review:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/59522/HTML/default/a001125856.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/59522/HTML/default/a001125856.htm&lt;/A&gt;</description>
      <pubDate>Thu, 18 Sep 2008 13:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47951#M12931</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-09-18T13:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47952#M12932</link>
      <description>Many thanks for your prompt response.&lt;BR /&gt;
&lt;BR /&gt;
For example:&lt;BR /&gt;
&lt;BR /&gt;
Dataset A  &lt;BR /&gt;
agegrp sex  stay_type  rate1&lt;BR /&gt;
1           1         1          10&lt;BR /&gt;
2           1         1          10&lt;BR /&gt;
3           1         1           8&lt;BR /&gt;
4           1         1           9&lt;BR /&gt;
5           1         1           7&lt;BR /&gt;
1            2        1           9&lt;BR /&gt;
2            2        1          10&lt;BR /&gt;
3            2         1         11&lt;BR /&gt;
4            2         1         13&lt;BR /&gt;
5            2        1           7&lt;BR /&gt;
1            1         2         15&lt;BR /&gt;
2             1        2         17&lt;BR /&gt;
3             1         2         9&lt;BR /&gt;
4             2         2         8&lt;BR /&gt;
&lt;BR /&gt;
Dataset B  &lt;BR /&gt;
agegrp sex  stay_type  rate2&lt;BR /&gt;
1           1         1          11&lt;BR /&gt;
2           1         1          12&lt;BR /&gt;
3           1         1           7&lt;BR /&gt;
4           1         1           9&lt;BR /&gt;
5           1       1           10&lt;BR /&gt;
1            2        1           9&lt;BR /&gt;
2            2        1          10&lt;BR /&gt;
3            2         1         11&lt;BR /&gt;
4            2         1         15&lt;BR /&gt;
5            2        1           7&lt;BR /&gt;
1            1         2         16&lt;BR /&gt;
2             1        2         17&lt;BR /&gt;
3             2         2         9&lt;BR /&gt;
4             2         2         8&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I need to calculate rate ratio (rate2/rate1) for each age-sex-stay type specific group.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Thu, 18 Sep 2008 13:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47952#M12932</guid>
      <dc:creator>Paris</dc:creator>
      <dc:date>2008-09-18T13:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47953#M12933</link>
      <description>With multiple observations for a unique BY variable set, you will need to use some SAS procedure (MEANS, SUMMARY, UNIVARIATE) to generate a reduced observation set before using a DATA step MERGE process.&lt;BR /&gt;
&lt;BR /&gt;
Suggest you start out with getting your data into SAS members using a SAS DATA step, then explore what "data summarization or analysis" procedure will work for you, and then review the DATA step process for merging using a BY statement, so you can perform your calculation.&lt;BR /&gt;
&lt;BR /&gt;
I encourage you to use the DOC and technical paper references cited previously.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 18 Sep 2008 13:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47953#M12933</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-09-18T13:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47954#M12934</link>
      <description>Thanks, Scott.&lt;BR /&gt;
&lt;BR /&gt;
What you have suggested is absolutely right. I have done proc summary to generate maximally one record for each age-sex-service specific group.  The problems are that (1) I need to match the two datasets by a set of variables rather than one and (2) there are many unmatched missing groups bwteen dataset1 and dataset2.</description>
      <pubDate>Thu, 18 Sep 2008 14:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47954#M12934</guid>
      <dc:creator>Paris</dc:creator>
      <dc:date>2008-09-18T14:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: Many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47955#M12935</link>
      <description>Okay.  A SAS DATA step MERGE with a BY statement, which supports multiple SAS variables.  It's unclear to me what you're expecting from SAS software, frankly? Again, I encourage you to show us *ALL* of your sample data, including the summarized level, and also the outcome of some MERGE process, for additional feedback.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 18 Sep 2008 14:13:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47955#M12935</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-09-18T14:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Many to many merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47956#M12936</link>
      <description>Hi Paris&lt;BR /&gt;
Looking at the example data you give us the combination of the variables agegrp,sex,stay_type (composite key) is unique. The relation between the two tables is 1:1.&lt;BR /&gt;
Have a look at the example below.  &lt;BR /&gt;
I used Proc SQL - you could do the same by first sorting the tables A and B by agegrp sex stay and then merge the sorted tables (merge A B; by agegrp sex stay;).&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick&lt;BR /&gt;
&lt;BR /&gt;
Data A;&lt;BR /&gt;
  input agegrp sex stay_type rate1;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
1 1 1 10&lt;BR /&gt;
2 1 1 10&lt;BR /&gt;
3 1 1 8&lt;BR /&gt;
4 1 1 9&lt;BR /&gt;
5 1 1 7&lt;BR /&gt;
1 2 1 9&lt;BR /&gt;
2 2 1 10&lt;BR /&gt;
3 2 1 11&lt;BR /&gt;
4 2 1 13&lt;BR /&gt;
5 2 1 7&lt;BR /&gt;
1 1 2 15&lt;BR /&gt;
2 1 2 17&lt;BR /&gt;
3 1 2 9&lt;BR /&gt;
4 2 2 8&lt;BR /&gt;
;&lt;BR /&gt;
Data B;&lt;BR /&gt;
  input agegrp sex stay_type rate2;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
1 1 1 11&lt;BR /&gt;
2 1 1 12&lt;BR /&gt;
3 1 1 7&lt;BR /&gt;
4 1 1 9&lt;BR /&gt;
5 1 1 10&lt;BR /&gt;
1 2 1 9&lt;BR /&gt;
2 2 1 10&lt;BR /&gt;
3 2 1 11&lt;BR /&gt;
4 2 1 15&lt;BR /&gt;
5 2 1 7&lt;BR /&gt;
1 1 2 16&lt;BR /&gt;
2 1 2 17&lt;BR /&gt;
3 2 2 9&lt;BR /&gt;
4 2 2 8&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
/*  create table CombinedAB as*/&lt;BR /&gt;
    select coalesce(l.agegrp,r.agegrp) as agegrp&lt;BR /&gt;
          ,coalesce(l.sex,r.sex) as sex&lt;BR /&gt;
          ,coalesce(l.stay_type,r.stay_type) as stay_type&lt;BR /&gt;
          ,l.rate1&lt;BR /&gt;
          ,r.rate2&lt;BR /&gt;
      from work.a l full join work.b r&lt;BR /&gt;
        on l.agegrp=r.agegrp and l.sex=r.sex and l.stay_type=r.stay_type&lt;BR /&gt;
      order by agegrp,sex,stay_type;&lt;BR /&gt;
quit;</description>
      <pubDate>Sat, 20 Sep 2008 01:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Many-to-many-merge/m-p/47956#M12936</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-09-20T01:48:19Z</dc:date>
    </item>
  </channel>
</rss>

