<?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 issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MERGE-issue/m-p/35605#M7053</link>
    <description>Hi Caramel.&lt;BR /&gt;
I suggest you collect the variables names before merging, and then only KEEP them in the output datasets. Either you name each list of variable names, or do it automatically -- as the program below suggests to do.&lt;BR /&gt;
[pre]&lt;BR /&gt;
PROC CONTENTS DATA=one OUT=dico_one NOPRINT ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC CONTENTS DATA=two OUT=dico_two NOPRINT ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC SQL NOPRINT ;&lt;BR /&gt;
  SELECT LEFT(TRIM(name)) INTO list_one SEPARATED BY " "&lt;BR /&gt;
  FROM dico_one ;&lt;BR /&gt;
  SELECT LEFT(TRIM(name)) INTO list_two SEPARATED BY " "&lt;BR /&gt;
  FROM dico_two ;&lt;BR /&gt;
QUIT ;&lt;BR /&gt;
data July31_11&lt;BR /&gt;
July31_10 (KEEP=&amp;amp;list_one)&lt;BR /&gt;
July31_01 (KEEP=&amp;amp;list_two) ; &lt;BR /&gt;
Merge one (in=ones) two (in=twos);&lt;BR /&gt;
by id sex age state;&lt;BR /&gt;
if ones=1 and twos=1 then output July31_11;&lt;BR /&gt;
if ones=1 and twos=0 then output July31_10;&lt;BR /&gt;
if ones=0 and twos=1 then output July31_01;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Olivier</description>
    <pubDate>Fri, 01 Aug 2008 07:33:39 GMT</pubDate>
    <dc:creator>Olivier</dc:creator>
    <dc:date>2008-08-01T07:33:39Z</dc:date>
    <item>
      <title>MERGE issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGE-issue/m-p/35604#M7052</link>
      <description>Is there a way to recover the original non-merge-matched observations without any additional variables? &lt;BR /&gt;
&lt;BR /&gt;
For example, suppose that I am trying to obtain three separate data sets using the following codes:&lt;BR /&gt;
&lt;BR /&gt;
data	July31_11&lt;BR /&gt;
	July31_10&lt;BR /&gt;
	July31_01; &lt;BR /&gt;
	Merge one (in=ones) two (in=twos);&lt;BR /&gt;
                by id sex age state;&lt;BR /&gt;
	if ones=1 and twos=1 then output July31_11;&lt;BR /&gt;
	if ones=1 and twos=0 then output July31_10;&lt;BR /&gt;
	if ones=0 and twos=1 then output July31_01;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
My problem is that although the July31_10 and July31_01 give me the non-merge-matched cases (cases whether one of the data set did not contribute to the current observation because of missing values or other reasons), these will contain anyway the same total number of variables as the July31_11 data set will have.  &lt;BR /&gt;
&lt;BR /&gt;
I am interested in obtain (“recover”) the non-contributing cases in their original form (as they was in their respective original data set) with the original set of variables.&lt;BR /&gt;
&lt;BR /&gt;
Do you have any suggestion? &lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Fri, 01 Aug 2008 03:04:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGE-issue/m-p/35604#M7052</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-08-01T03:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: MERGE issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGE-issue/m-p/35605#M7053</link>
      <description>Hi Caramel.&lt;BR /&gt;
I suggest you collect the variables names before merging, and then only KEEP them in the output datasets. Either you name each list of variable names, or do it automatically -- as the program below suggests to do.&lt;BR /&gt;
[pre]&lt;BR /&gt;
PROC CONTENTS DATA=one OUT=dico_one NOPRINT ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC CONTENTS DATA=two OUT=dico_two NOPRINT ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
PROC SQL NOPRINT ;&lt;BR /&gt;
  SELECT LEFT(TRIM(name)) INTO list_one SEPARATED BY " "&lt;BR /&gt;
  FROM dico_one ;&lt;BR /&gt;
  SELECT LEFT(TRIM(name)) INTO list_two SEPARATED BY " "&lt;BR /&gt;
  FROM dico_two ;&lt;BR /&gt;
QUIT ;&lt;BR /&gt;
data July31_11&lt;BR /&gt;
July31_10 (KEEP=&amp;amp;list_one)&lt;BR /&gt;
July31_01 (KEEP=&amp;amp;list_two) ; &lt;BR /&gt;
Merge one (in=ones) two (in=twos);&lt;BR /&gt;
by id sex age state;&lt;BR /&gt;
if ones=1 and twos=1 then output July31_11;&lt;BR /&gt;
if ones=1 and twos=0 then output July31_10;&lt;BR /&gt;
if ones=0 and twos=1 then output July31_01;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Olivier</description>
      <pubDate>Fri, 01 Aug 2008 07:33:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGE-issue/m-p/35605#M7053</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-08-01T07:33:39Z</dc:date>
    </item>
  </channel>
</rss>

