<?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: Merging two datasets with different number of rows per id in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467626#M119381</link>
    <description>&lt;P&gt;Good catch,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding the other concerns, such as creating a table, being able to use it, all of those should be fine.&amp;nbsp; Just test it on your own test data to verify for yourself.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jun 2018 11:19:47 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-06-05T11:19:47Z</dc:date>
    <item>
      <title>Merging two datasets with different number of rows per id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467554#M119350</link>
      <description>&lt;P&gt;Hello all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two datasets with a different number of rows per person_id, and I would like to merge the two datasets in a way that each row from dataset B gets added to all rows for that corresponding person in dataset A.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an example of what the original datasets would look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATASET A:&lt;/P&gt;&lt;P&gt;id &amp;nbsp;value&lt;/P&gt;&lt;P&gt;1 &amp;nbsp;A&lt;/P&gt;&lt;P&gt;1 &amp;nbsp;B&lt;/P&gt;&lt;P&gt;1 &amp;nbsp;C&lt;/P&gt;&lt;P&gt;2 &amp;nbsp;A&lt;/P&gt;&lt;P&gt;2 &amp;nbsp;C&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATASET B:&lt;/P&gt;&lt;P&gt;id &amp;nbsp;med &amp;nbsp; start_date &amp;nbsp; end_date&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/5/13 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/10/16&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3/10/16 &amp;nbsp; &amp;nbsp; &amp;nbsp;4/10/16&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/8/13 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/10/13&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3/5/18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/3/18&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5/5/18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6/1/18&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I would like the merged dataset to look like:&lt;/P&gt;&lt;P&gt;id value &amp;nbsp;&lt;SPAN&gt;med &amp;nbsp; start_date &amp;nbsp; end_date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/5/13 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/10/16&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3/10/16 &amp;nbsp; &amp;nbsp; &amp;nbsp;4/10/16&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/5/13 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/10/16&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3/10/16 &amp;nbsp; &amp;nbsp; &amp;nbsp;4/10/16&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/5/13 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2/10/16&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3/10/16 &amp;nbsp; &amp;nbsp; &amp;nbsp;4/10/16&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/8/13 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/10/13&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3/5/18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/3/18&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5/5/18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6/1/18&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/8/13 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/10/13&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3/5/18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/3/18&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5/5/18 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6/1/18&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can anyone advise me how I can merge the two datasets so that all rows for each person in dataset B gets added to each row for that same person in dataset A?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your help!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 01:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467554#M119350</guid>
      <dc:creator>SarahW13</dc:creator>
      <dc:date>2018-06-05T01:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets with different number of rows per id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467555#M119351</link>
      <description>&lt;P&gt;The easiest way is PROC SQL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as&lt;/P&gt;
&lt;P&gt;select a.value, b.* where a.id = b.id;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 02:01:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467555#M119351</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-05T02:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets with different number of rows per id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467556#M119352</link>
      <description>&lt;P&gt;Astounding, thanks for the reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to actually do this as a data step without creating a table in proc sql? My understanding about proc sql tables is that I can't actually use that table as a dataset. I want to do this merge in a way that creates an actual dataset that I can manipulate further.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 02:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467556#M119352</guid>
      <dc:creator>SarahW13</dc:creator>
      <dc:date>2018-06-05T02:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets with different number of rows per id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467563#M119354</link>
      <description>Proc SQL creates datasets if you have the CREATE TABLE portion. The SELECT alone does not.</description>
      <pubDate>Tue, 05 Jun 2018 03:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467563#M119354</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-05T03:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets with different number of rows per id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467567#M119355</link>
      <description>&lt;P&gt;I didn't know that (about the create table option).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code from Astounding doesn't seem to be working when I try it. I think I'm just not using it correctly. Astounding (or anyone else), could you clarify that code for me?&amp;nbsp;For the code a.value, would "a" be referring to the dataset name and "value" referring to the variable name?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the example datasets that I gave, I would be trying to copy all columns (value, med, start_date, end_date), with the four values for each id getting added to all rows for that corresponding id from the other dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 04:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467567#M119355</guid>
      <dc:creator>SarahW13</dc:creator>
      <dc:date>2018-06-05T04:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets with different number of rows per id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467583#M119363</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;'s code is missing the "from" part of the create table/select statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select a.value, b.*
from a, b
where a.id = b.id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jun 2018 06:25:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467583#M119363</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-05T06:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets with different number of rows per id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467625#M119380</link>
      <description>&lt;P&gt;I don't think merge will give you the desired result, the best way to do this is by proc sql.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 11:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467625#M119380</guid>
      <dc:creator>ruchi11dec</dc:creator>
      <dc:date>2018-06-05T11:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets with different number of rows per id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467626#M119381</link>
      <description>&lt;P&gt;Good catch,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding the other concerns, such as creating a table, being able to use it, all of those should be fine.&amp;nbsp; Just test it on your own test data to verify for yourself.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 11:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467626#M119381</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-05T11:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets with different number of rows per id</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467685#M119414</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194212"&gt;@SarahW13&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I didn't know that (about the create table option).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code from Astounding doesn't seem to be working when I try it. I think I'm just not using it correctly. Astounding (or anyone else), could you clarify that code for me?&amp;nbsp;For the code a.value, would "a" be referring to the dataset name and "value" referring to the variable name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the example datasets that I gave, I would be trying to copy all columns (value, med, start_date, end_date), with the four values for each id getting added to all rows for that corresponding id from the other dataset.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If something isn't working please post the non working code and the log at minimum.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 14:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-with-different-number-of-rows-per-id/m-p/467685#M119414</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-05T14:48:44Z</dc:date>
    </item>
  </channel>
</rss>

