<?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: match-merge doesn't work, and I don't know why in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196138#M36862</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you have problems matching variables, convert their values into new variables with a $HEX. format and look at the hex values. You will see previously undetectable characters/circumstances that cause the comparison to fail.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Aug 2015 08:21:08 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2015-08-11T08:21:08Z</dc:date>
    <item>
      <title>match-merge doesn't work, and I don't know why</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196134#M36858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to match-merge a small file consisting of lastname and firstname (plus other stuff) with a large reference table. The match is to be done on lastname and firstname (in that order).&amp;nbsp; Basically, I need to add some information from the reference to the records in the small file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've done everything I can think of to assure that the match variables are formatted identically -- same informat, same format, trimmed out leading and trailing blanks -- but the match-merge doesn't work. Yes, the two files are both sorted on the two match variables. Yes, I did include a BY statement, using the same two variables in the same order. It looks like SAS is concatenating the files instead of merging them -- I get all the records from one file with all variables from the other as missing values, followed by the records from the other table (without the non-matched variables from the first one). If I use the (IN=) option for the small file, I simply get the same file with the addition of blanks in the variables brought in from the other file. The reverse happens if I use (IN=) on the large file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To summarize, the small file was created this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;DATA WORK.small;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFILE '[file path].csv&amp;nbsp; DELIMITER= ','&amp;nbsp; MISSOVER&amp;nbsp; DSD&amp;nbsp; LRECL=32767&amp;nbsp; FIRSTOBS=2;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFORMAT ID best32. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFORMAT Lastname $30. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFORMAT Firstname $30. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT ID best12. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT Lastname $30. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT Firstname $30. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; INPUT&amp;nbsp; ID&amp;nbsp; Lastname $&amp;nbsp; Firstname $ ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And here is how the reference file was read in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;DATA WORK.large;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFILE '[file path].csv'&amp;nbsp; DELIMITER= ','&amp;nbsp; MISSOVER&amp;nbsp; DSD&amp;nbsp; LRECL=32767&amp;nbsp; FIRSTOBS=2;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFORMAT add_this_info&amp;nbsp; $11. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFORMAT Lastname $30. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFORMAT Firstname $30. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INFORMAT Name $40. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT add_this_info&amp;nbsp; $11. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT Lastname $30. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT Firstname $30. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT Name $40. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT add_this_info&amp;nbsp; $11. ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; INPUT&amp;nbsp; add_this_info $&amp;nbsp; Lastname $&amp;nbsp; Firstname $&amp;nbsp; Name $ ;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both files were sorted on lastname and firstname (in that order), and then I wrote the match-merge:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;DATA match_merge;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MERGE large small(IN=keep);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY lastname firstname;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF keep=1;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;run;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;For testing, the IF statement may or may not appear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've even concatenated the lastname and firstname into a single field (that's not the "Name" field in the large file), using the COMPRESS and TRIM functions to assure that the fields are exactly alike. Same thing happens.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is absolutely certain that some records in the small file have corresponding records in the large file -- I can eyeball that. But SAS doesn't see what I do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2015 22:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196134#M36858</guid>
      <dc:creator>NealTinWA</dc:creator>
      <dc:date>2015-08-10T22:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: match-merge doesn't work, and I don't know why</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196135#M36859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;did you try&lt;/P&gt;&lt;P&gt;MERGE&amp;nbsp; small(IN=keep) large;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead of&lt;/P&gt;&lt;P&gt;MERGE large small(IN=keep);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;order of appearance in the merge statement is important&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2015 23:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196135#M36859</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-08-10T23:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: match-merge doesn't work, and I don't know why</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196136#M36860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try a SQL merge to test if it's something wrong with your data or your data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select a.*, b.ID&lt;/P&gt;&lt;P&gt;from a&lt;/P&gt;&lt;P&gt;left join b&lt;/P&gt;&lt;P&gt;on a.first_name=b.first_name &lt;/P&gt;&lt;P&gt;and a.last_name=b.last_name&lt;/P&gt;&lt;P&gt;order by b.last_name;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2015 23:28:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196136#M36860</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-08-10T23:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: match-merge doesn't work, and I don't know why</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196137#M36861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried getting rid of the INFORMAT statements?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The FORMAT statements should be sufficient to establish the lengths of the variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 01:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196137#M36861</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-08-11T01:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: match-merge doesn't work, and I don't know why</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196138#M36862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you have problems matching variables, convert their values into new variables with a $HEX. format and look at the hex values. You will see previously undetectable characters/circumstances that cause the comparison to fail.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 08:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196138#M36862</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-08-11T08:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: match-merge doesn't work, and I don't know why</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196139#M36863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes! That was the problem. There was a hidden hex character in the small file's lastname field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Interestingly (or not) I couldn't see it if I read the flat file as a CSV, but it was visible if read as a TXT file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in the end, I did make a mistake ... but a far different one than I thought I might be making.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 16:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196139#M36863</guid>
      <dc:creator>NealTinWA</dc:creator>
      <dc:date>2015-08-11T16:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: match-merge doesn't work, and I don't know why</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196140#M36864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Very nice! That's definitely going in my toolbox.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 18:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196140#M36864</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2015-08-11T18:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: match-merge doesn't work, and I don't know why</title>
      <link>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196141#M36865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let me guess: you looked at the CSV with a spreadsheet program. They do tend to obscure some things.&lt;/P&gt;&lt;P&gt;You can look at CSV with NOTEPAD or similar plain text editors (not Wordpad which supports additional appearance stuff) as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 19:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/match-merge-doesn-t-work-and-I-don-t-know-why/m-p/196141#M36865</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-08-11T19:09:38Z</dc:date>
    </item>
  </channel>
</rss>

