<?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: SAS Merge statement  Any solution to join my problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32574#M6295</link>
    <description>There will be some truncation because of the way the variables (C3 and C5) are defined in your test data sets (A and B), otherwise it seems like you should be successful.  What exactly is not working?</description>
    <pubDate>Thu, 11 Nov 2010 20:12:21 GMT</pubDate>
    <dc:creator>ArtC</dc:creator>
    <dc:date>2010-11-11T20:12:21Z</dc:date>
    <item>
      <title>SAS Merge statement  Any solution to join my problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32573#M6294</link>
      <description>I have two datasets. If the record is in both the datasets then I dont want that. If its only find in any of the dataset then I want that record to be output to different dataset.&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
	c1=1; c2="aaa"; c3="1"; c4="ss1"; c5="gg"; output;&lt;BR /&gt;
	c1=2; c2="aaa"; c3="1-1"; c4="ss"; c5="ff"; output;&lt;BR /&gt;
	c1=3; c2="bbb"; c3="2"; c4="ss"; c5="yyy"; output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data b;&lt;BR /&gt;
	c1=1; c2="aaa"; c3="1"; c4="ss1"; c5="gg"; output;&lt;BR /&gt;
	c1=2; c2="ccc"; c3="1-1"; c4="ss"; c5="rtr"; output;&lt;BR /&gt;
	c1=3; c2="bbb"; c3="2"; c4="ss"; c5="hhj"; output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data d e;&lt;BR /&gt;
	merge a(in=in1) b(in=in2); by c1 c2;&lt;BR /&gt;
	if (in1=1 and in2=0) then output d;&lt;BR /&gt;
	if (in1=0 and in2=1) then output e;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The dataset d should contain below observations&lt;BR /&gt;
c1=2; c2="aaa"; c3="1-1"; c4="ss"; c5="ff"; output;&lt;BR /&gt;
&lt;BR /&gt;
ant the dataset e should contain&lt;BR /&gt;
&lt;BR /&gt;
c1=2; c2="ccc"; c3="1-1"; c4="ss"; c5="rtr"; output;&lt;BR /&gt;
&lt;BR /&gt;
Any body has idea how to acheive this.</description>
      <pubDate>Thu, 11 Nov 2010 19:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32573#M6294</guid>
      <dc:creator>anandbillava</dc:creator>
      <dc:date>2010-11-11T19:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Merge statement  Any solution to join my problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32574#M6295</link>
      <description>There will be some truncation because of the way the variables (C3 and C5) are defined in your test data sets (A and B), otherwise it seems like you should be successful.  What exactly is not working?</description>
      <pubDate>Thu, 11 Nov 2010 20:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32574#M6295</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2010-11-11T20:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Merge statement  Any solution to join my problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32575#M6296</link>
      <description>Is there  any limit for the by variable.</description>
      <pubDate>Thu, 11 Nov 2010 20:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32575#M6296</guid>
      <dc:creator>anandbillava</dc:creator>
      <dc:date>2010-11-11T20:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Merge statement  Any solution to join my problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32576#M6297</link>
      <description>Hi:&lt;BR /&gt;
  What is the issue you're seeing that leads you to wonder about the limit for the BY variable? Are you doing one-to-one merging, one-to-many merging or many-to-many merging in the "real" data. With just 3 test observations in each data set, it is hard to understand your issue or what leads you to ask about BY variables.&lt;BR /&gt;
 &lt;BR /&gt;
  If you are seeing this message in the log with your "REAL" data, &lt;BR /&gt;
[pre]&lt;BR /&gt;
NOTE: MERGE statement has more than one data set with repeats of BY values.&lt;BR /&gt;
[/pre]&lt;BR /&gt;
               &lt;BR /&gt;
it generally indicates that you are doing a many-to-many merge, which may produce undesireable results, as explained in the Tech Support note:&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/24/752.html" target="_blank"&gt;http://support.sas.com/kb/24/752.html&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 11 Nov 2010 21:07:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32576#M6297</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-11T21:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Merge statement  Any solution to join my problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32577#M6298</link>
      <description>Hello Anandbilava,&lt;BR /&gt;
&lt;BR /&gt;
As AtrC noticed you have a truncation error in your character variables c3-c5 in the a and b datasets. If you add the line &lt;BR /&gt;
&lt;BR /&gt;
length c1 8 c2 c3 c4 c5 $3; &lt;BR /&gt;
&lt;BR /&gt;
after data a; and data b; then everything should work fine. At least it is true for my computer.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Fri, 12 Nov 2010 17:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Merge-statement-Any-solution-to-join-my-problem/m-p/32577#M6298</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-11-12T17:14:59Z</dc:date>
    </item>
  </channel>
</rss>

