<?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 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132419#M36025</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd be willing to bet money your strings are not 100% the same due to being case sensitive. remember sas is case sensitive, this includes its joins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data person;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile datalines delimiter=',';&lt;/P&gt;&lt;P&gt;input namekey $ firstvar;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;John,1&lt;/P&gt;&lt;P&gt;Mary,2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data person1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile datalines delimiter=',';&lt;/P&gt;&lt;P&gt;input namekey $ secondvar;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;JOHN,1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=person;&lt;/P&gt;&lt;P&gt;by namekey;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=person1;&lt;/P&gt;&lt;P&gt;by namekey;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data didntwork;&lt;/P&gt;&lt;P&gt;merge person(in=a) person1(in=b);&lt;/P&gt;&lt;P&gt;by namekey;&lt;/P&gt;&lt;P&gt;if a=1 and b=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This process will return a dataset that has BOTH John and Mary, because neither of these values exist in the other table (John doesn't exist, but JOHN does).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do an upcase on your fields before you merge and see if that fixes it. If you are 100% positive that your cases are the same, then what you are describing cannot happen in sas by the definition of merges. If it is, append some of your actual data for us to confirm, and then follow along with SAS support.&lt;/P&gt;&lt;P&gt;Brandon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 May 2013 22:40:55 GMT</pubDate>
    <dc:creator>Anotherdream</dc:creator>
    <dc:date>2013-05-08T22:40:55Z</dc:date>
    <item>
      <title>Merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132413#M36019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;i am merging two data sets by the common key variable-MRN&lt;/P&gt;&lt;P&gt;DAta dataset1 dataset2;&lt;/P&gt;&lt;P&gt;merge have1(in=a) have2(in=b);&lt;/P&gt;&lt;P&gt;BY mrn ;&lt;/P&gt;&lt;P&gt;if a and(not b) then output dataset1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;unfortunately in dataset1 i am getting MRN's which are present (common)in both data sets&lt;/P&gt;&lt;P&gt;i tried compress and strip for mrn variable. it Dont work&lt;/P&gt;&lt;P&gt;MRN is a char variable&lt;/P&gt;&lt;P&gt;COuld you tell where I went wrong???&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 07:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132413#M36019</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-05-08T07:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132414#M36020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try with Proc Sql joins...Left Join, Right Join...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 11:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132414#M36020</guid>
      <dc:creator>UrvishShah</dc:creator>
      <dc:date>2013-05-08T11:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132415#M36021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's hard to without the actual data.&lt;/P&gt;&lt;P&gt;It seems that the program you attached is not the one you are actually using, it should produce an error (no space between "and" and the "(".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 11:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132415#M36021</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-05-08T11:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132416#M36022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a join won't do this, you need to do stuff like intersect to make this happen, or some kind of where on the join result.&lt;/P&gt;&lt;P&gt;So for this case, I prefer the chosen method...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 11:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132416#M36022</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-05-08T11:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132417#M36023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried your code as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data have1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input mrn $;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; datalines;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;aaa&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;bbb&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ccc&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ddd&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;eee&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data have2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input mrn $;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; datalines;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;aaa&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ccc&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;eee&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;DAta dataset1 dataset2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;merge have1(in=a) have2(in=b);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;BY mrn ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;if a and(not b) then output dataset1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and it worked as expected, giving:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NOTE: There were 5 observations read from the data set WORK.HAVE1.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NOTE: There were 3 observations read from the data set WORK.HAVE2.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NOTE: The data set WORK.DATASET1 has 2 observations and 1 variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NOTE: The data set WORK.DATASET2 has 0 observations and 1 variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The "and(" was not a problem, token handling takes care of that, but generally speaking it would be clearer if there was a space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please provide some example input and the faulty output results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 12:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132417#M36023</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2013-05-08T12:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132418#M36024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not possible, most of the time.&amp;nbsp; If you are sure you are really getting this result, it could indicate that one of your data sets actually contains a variable named B with values of 0 or missing, which overrides the value generated by&amp;nbsp; HAVE2 (IN=B).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 12:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132418#M36024</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-05-08T12:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132419#M36025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd be willing to bet money your strings are not 100% the same due to being case sensitive. remember sas is case sensitive, this includes its joins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data person;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile datalines delimiter=',';&lt;/P&gt;&lt;P&gt;input namekey $ firstvar;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;John,1&lt;/P&gt;&lt;P&gt;Mary,2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data person1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile datalines delimiter=',';&lt;/P&gt;&lt;P&gt;input namekey $ secondvar;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;JOHN,1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=person;&lt;/P&gt;&lt;P&gt;by namekey;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=person1;&lt;/P&gt;&lt;P&gt;by namekey;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data didntwork;&lt;/P&gt;&lt;P&gt;merge person(in=a) person1(in=b);&lt;/P&gt;&lt;P&gt;by namekey;&lt;/P&gt;&lt;P&gt;if a=1 and b=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This process will return a dataset that has BOTH John and Mary, because neither of these values exist in the other table (John doesn't exist, but JOHN does).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do an upcase on your fields before you merge and see if that fixes it. If you are 100% positive that your cases are the same, then what you are describing cannot happen in sas by the definition of merges. If it is, append some of your actual data for us to confirm, and then follow along with SAS support.&lt;/P&gt;&lt;P&gt;Brandon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 22:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Merge/m-p/132419#M36025</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-05-08T22:40:55Z</dc:date>
    </item>
  </channel>
</rss>

