<?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: merge data with unequal observations in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47096#M12604</link>
    <description>sounds like : take one case for each ID of AGE and BMI (hopefully there would only be one unique pair of values for one ID ) apply in 1:n merge with data2 by ID&lt;BR /&gt;
proc sql _method ;&lt;BR /&gt;
  create table joined as&lt;BR /&gt;
      select a.*, b.age, b.bmi&lt;BR /&gt;
         from data2 as a&lt;BR /&gt;
         join (select distinct id, age, bmi from data1 ) as b&lt;BR /&gt;
           on a.id=b.id  &lt;BR /&gt;
       ;&lt;BR /&gt;
quit ;&lt;BR /&gt;
proc print ;&lt;BR /&gt;
run ;</description>
    <pubDate>Sat, 20 Jun 2009 16:58:48 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2009-06-20T16:58:48Z</dc:date>
    <item>
      <title>merge data with unequal observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47092#M12600</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am trying to add AGE and BMI data in data1 to the data2 based on #ID. Since the two data sets have different No. of observations, I have trouble to add them. Could some one help me with this?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
DATA1&lt;BR /&gt;
#ID	AGE	BMI                                  &lt;BR /&gt;
5001	41	22.7&lt;BR /&gt;
5001	41	22.7&lt;BR /&gt;
5001	41	22.7&lt;BR /&gt;
5003	50	24.5&lt;BR /&gt;
5003	50	24.5&lt;BR /&gt;
5003	50	24.5&lt;BR /&gt;
5003	50	24.5&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
DATA2&lt;BR /&gt;
#ID	TIME	AMT &lt;BR /&gt;
5001 0	0&lt;BR /&gt;
50010	0&lt;BR /&gt;
5001	0	0&lt;BR /&gt;
5001	0	0&lt;BR /&gt;
5001	0	0&lt;BR /&gt;
5001	0.01	6800&lt;BR /&gt;
5001	0.01	6800&lt;BR /&gt;
5001	0.01	6800&lt;BR /&gt;
5001	0.083	0&lt;BR /&gt;
5003	0	.&lt;BR /&gt;
5003	0.01	8900&lt;BR /&gt;
5003	0.083	.&lt;BR /&gt;
5003	0.167	.&lt;BR /&gt;
5003	0.25	.&lt;BR /&gt;
5003	0.333	.&lt;BR /&gt;
5003	0.5	.&lt;BR /&gt;
5003	0.75	.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
..&lt;BR /&gt;
	.</description>
      <pubDate>Sat, 20 Jun 2009 00:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47092#M12600</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-20T00:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: merge data with unequal observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47093#M12601</link>
      <description>You should explain what the OUTPUT side (expected) is to appear.  The MERGE process can use a BY statement, listing the merge variable values.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sat, 20 Jun 2009 01:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47093#M12601</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-20T01:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: merge data with unequal observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47094#M12602</link>
      <description>&amp;gt; You should explain what the OUTPUT side (expected) is&lt;BR /&gt;
&amp;gt; to appear.  The MERGE process can use a BY statement,&lt;BR /&gt;
&amp;gt; listing the merge variable values.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Scott Barry&lt;BR /&gt;
&amp;gt; SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
sorry about that.&lt;BR /&gt;
&lt;BR /&gt;
The output should be like following:&lt;BR /&gt;
#ID	TIME	AMT	AGE	BMI&lt;BR /&gt;
5001	0	0	41	22.7&lt;BR /&gt;
5001	0	0	41	22.7&lt;BR /&gt;
5001	0	0	41	22.7&lt;BR /&gt;
5001	0	0	41	22.7&lt;BR /&gt;
5001	0	0	41	22.7&lt;BR /&gt;
5001	0.01	6800	41	22.7&lt;BR /&gt;
5001	0.01	6800	41	22.7&lt;BR /&gt;
5001	0.01	6800	41	22.7&lt;BR /&gt;
5001	0.083	0	41	22.7&lt;BR /&gt;
5003	0	.	50	24.5&lt;BR /&gt;
5003	0.01	8900	50	24.5&lt;BR /&gt;
5003	0.083	.	50	24.5&lt;BR /&gt;
5003	0.167	.	50	24.5&lt;BR /&gt;
5003	0.25	.	50	24.5&lt;BR /&gt;
5003	0.333	.	50	24.5&lt;BR /&gt;
5003	0.5	.	50	24.5&lt;BR /&gt;
5003	0.75	.	50	24.5</description>
      <pubDate>Sat, 20 Jun 2009 01:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47094#M12602</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-06-20T01:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: merge data with unequal observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47095#M12603</link>
      <description>As was suggested, with your two files loaded as SAS datasets, sort and use a DATA step MERGE with a BY statement.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sat, 20 Jun 2009 13:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47095#M12603</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-20T13:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: merge data with unequal observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47096#M12604</link>
      <description>sounds like : take one case for each ID of AGE and BMI (hopefully there would only be one unique pair of values for one ID ) apply in 1:n merge with data2 by ID&lt;BR /&gt;
proc sql _method ;&lt;BR /&gt;
  create table joined as&lt;BR /&gt;
      select a.*, b.age, b.bmi&lt;BR /&gt;
         from data2 as a&lt;BR /&gt;
         join (select distinct id, age, bmi from data1 ) as b&lt;BR /&gt;
           on a.id=b.id  &lt;BR /&gt;
       ;&lt;BR /&gt;
quit ;&lt;BR /&gt;
proc print ;&lt;BR /&gt;
run ;</description>
      <pubDate>Sat, 20 Jun 2009 16:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/merge-data-with-unequal-observations/m-p/47096#M12604</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-06-20T16:58:48Z</dc:date>
    </item>
  </channel>
</rss>

