<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/411365#M100562</link>
    <description>&lt;P&gt;Normally that is not what people want to do when they have two datasets with repeating by groups, but luckily for you it is very similar to how SAS data step merge handles combining observations when datasets contribute multiple observations per group.&amp;nbsp; But normal SAS behavior is to retain the values from the last observation of the dataset with fewer observations.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot prevent the retaining, but you can add code to write the observation and then clear all of the variables so nothing is retained.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  merge A B ;
  by sub ;
  output;
  call missing(of _all_);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2017 20:46:31 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-11-07T20:46:31Z</dc:date>
    <item>
      <title>Merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/411335#M100553</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Data A:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sub&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; model&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CT&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;US&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xR&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CP&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data B:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sub&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; model_site&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CT&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FG&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;YG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;need final result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sub&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; model&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;model_site&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;CT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CT&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; US&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FG&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xR&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; YG&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CP&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;basically i have 2 different data set with subject and model. 'A' data set has 4 observations and 'B' data set has 3 observation. i need to&amp;nbsp;merge this data set by Subject&amp;nbsp; but i need to last row of&amp;nbsp; model_site is missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 19:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/411335#M100553</guid>
      <dc:creator>dhrums28</dc:creator>
      <dc:date>2017-11-07T19:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/411346#M100555</link>
      <description>&lt;P&gt;Assuming you have already sorted your data sets, here is the simplest way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge A B;&lt;/P&gt;
&lt;P&gt;by sub;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;model = ' ';&lt;/P&gt;
&lt;P&gt;model_site = ' ';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 20:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/411346#M100555</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-07T20:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/411358#M100559</link>
      <description>&lt;P&gt;Do you have multiple subjects?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise a MERGE without a BY statement is all you need, but I highly suspect your problem is more complicated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure your sample data accurately reflects your real data.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 20:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/411358#M100559</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-07T20:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/411365#M100562</link>
      <description>&lt;P&gt;Normally that is not what people want to do when they have two datasets with repeating by groups, but luckily for you it is very similar to how SAS data step merge handles combining observations when datasets contribute multiple observations per group.&amp;nbsp; But normal SAS behavior is to retain the values from the last observation of the dataset with fewer observations.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot prevent the retaining, but you can add code to write the observation and then clear all of the variables so nothing is retained.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  merge A B ;
  by sub ;
  output;
  call missing(of _all_);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 20:46:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/411365#M100562</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-07T20:46:31Z</dc:date>
    </item>
  </channel>
</rss>

