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). Basically, I need to add some information from the reference to the records in the small file. 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. To summarize, the small file was created this way: DATA WORK.small; INFILE '[file path].csv DELIMITER= ',' MISSOVER DSD LRECL=32767 FIRSTOBS=2; INFORMAT ID best32. ; INFORMAT Lastname $30. ; INFORMAT Firstname $30. ; FORMAT ID best12. ; FORMAT Lastname $30. ; FORMAT Firstname $30. ; INPUT ID Lastname $ Firstname $ ; run; And here is how the reference file was read in: DATA WORK.large; INFILE '[file path].csv' DELIMITER= ',' MISSOVER DSD LRECL=32767 FIRSTOBS=2; INFORMAT add_this_info $11. ; INFORMAT Lastname $30. ; INFORMAT Firstname $30. ; INFORMAT Name $40. ; FORMAT add_this_info $11. ; FORMAT Lastname $30. ; FORMAT Firstname $30. ; FORMAT Name $40. ; FORMAT add_this_info $11. ; INPUT add_this_info $ Lastname $ Firstname $ Name $ ; run; Both files were sorted on lastname and firstname (in that order), and then I wrote the match-merge: DATA match_merge; MERGE large small(IN=keep); BY lastname firstname; IF keep=1; run; For testing, the IF statement may or may not appear. 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. 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. Why??
... View more