<?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: Problem with MERGE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-MERGE/m-p/72466#M15613</link>
    <description>This appears to work with your example data.  Test it and see for yourself.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data tmp_2008;&lt;BR /&gt;
   input id $ dat_2008:datetime.;&lt;BR /&gt;
   format dat_: datetime.;&lt;BR /&gt;
   cards;&lt;BR /&gt;
33882041 16MAR2011:18:27:21&lt;BR /&gt;
   run;&lt;BR /&gt;
data tmp_2009;&lt;BR /&gt;
   input id $ dat_2009:datetime.;&lt;BR /&gt;
   format dat_: datetime.;&lt;BR /&gt;
   cards;&lt;BR /&gt;
33882041 17MAR2011:17:40:03&lt;BR /&gt;
33882041 22MAR2011:18:06:49&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
DATA tmp;&lt;BR /&gt;
   MERGE &lt;BR /&gt;
      tmp_2008 (in=a keep=id dat_2008)&lt;BR /&gt;
      tmp_2009 (in=b keep=id dat_2009)&lt;BR /&gt;
      ;&lt;BR /&gt;
   BY id;&lt;BR /&gt;
   output;&lt;BR /&gt;
   call missing(of dat_:);&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]

Message was edited by: data _null_;</description>
    <pubDate>Fri, 03 Jun 2011 14:45:58 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2011-06-03T14:45:58Z</dc:date>
    <item>
      <title>Problem with MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-MERGE/m-p/72464#M15611</link>
      <description>Hi everybody,&lt;BR /&gt;
&lt;BR /&gt;
When I'm merging two data sets A and B by a common variable ID, if there are two rows entirely filled for an ID in A and one row partially filled for the same ID in B, after the merge I obtain 2 rows entirely filled (missing values in B are replaced by A values).&lt;BR /&gt;
The problem is I would like to keep an empty field, of course.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Here is my code :&lt;BR /&gt;
&lt;BR /&gt;
**********************************************************&lt;BR /&gt;
DATA tmp;&lt;BR /&gt;
MERGE&lt;BR /&gt;
tmp_2008 (in=a keep=id dat_2008)&lt;BR /&gt;
tmp_2009 (in=b keep=id dat_2009)&lt;BR /&gt;
BY id;&lt;BR /&gt;
run;&lt;BR /&gt;
**********************************************************&lt;BR /&gt;
&lt;BR /&gt;
And the result :&lt;BR /&gt;
&lt;BR /&gt;
id----------------dat_2008----------------------dat_2009----------&lt;BR /&gt;
&lt;BR /&gt;
33882041 -- 16MAR2011:18:27:21 -- 17MAR2011:17:40:03&lt;BR /&gt;
33882041 -- 16MAR2011:18:27:21 -- 22MAR2011:18:06:49&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
(Before merging, I have two rows in dat_2009, one in dat_2008 and after merging these data sets I don't want the duplicate value in the second row for dat_2008 but keep the field empty).&lt;BR /&gt;
&lt;BR /&gt;
Hope to make myself clear, &lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 03 Jun 2011 13:32:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-MERGE/m-p/72464#M15611</guid>
      <dc:creator>romain</dc:creator>
      <dc:date>2011-06-03T13:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-MERGE/m-p/72465#M15612</link>
      <description>You will need to use different SAS variable names and populate your KEEP variable(s) in your DATA step based on the IN= variable conditions.  What behavior you are seeing is the SAS architecture standard with MERGE processing -- any other desired result requires the use of alternate-named SAS variables and your own tests for missing/blank value logic.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 03 Jun 2011 14:27:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-MERGE/m-p/72465#M15612</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-06-03T14:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-MERGE/m-p/72466#M15613</link>
      <description>This appears to work with your example data.  Test it and see for yourself.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data tmp_2008;&lt;BR /&gt;
   input id $ dat_2008:datetime.;&lt;BR /&gt;
   format dat_: datetime.;&lt;BR /&gt;
   cards;&lt;BR /&gt;
33882041 16MAR2011:18:27:21&lt;BR /&gt;
   run;&lt;BR /&gt;
data tmp_2009;&lt;BR /&gt;
   input id $ dat_2009:datetime.;&lt;BR /&gt;
   format dat_: datetime.;&lt;BR /&gt;
   cards;&lt;BR /&gt;
33882041 17MAR2011:17:40:03&lt;BR /&gt;
33882041 22MAR2011:18:06:49&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
DATA tmp;&lt;BR /&gt;
   MERGE &lt;BR /&gt;
      tmp_2008 (in=a keep=id dat_2008)&lt;BR /&gt;
      tmp_2009 (in=b keep=id dat_2009)&lt;BR /&gt;
      ;&lt;BR /&gt;
   BY id;&lt;BR /&gt;
   output;&lt;BR /&gt;
   call missing(of dat_:);&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]

Message was edited by: data _null_;</description>
      <pubDate>Fri, 03 Jun 2011 14:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-MERGE/m-p/72466#M15613</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-06-03T14:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with MERGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-with-MERGE/m-p/72467#M15614</link>
      <description>I was trying to do what sbb said.&lt;BR /&gt;
&lt;BR /&gt;
Your solution works perfectly data _null_;&lt;BR /&gt;
&lt;BR /&gt;
Thank you both.</description>
      <pubDate>Fri, 03 Jun 2011 14:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-with-MERGE/m-p/72467#M15614</guid>
      <dc:creator>romain</dc:creator>
      <dc:date>2011-06-03T14:56:01Z</dc:date>
    </item>
  </channel>
</rss>

