How would I code a merge that will write the matches of both to one data set, the non-matches from the left-most data.
Left join in SQL, or a suitable data step merge. For a more detailed answer, please provide example data in usable form (data steps with datelines, see my footnotes).
The devil is in the details of what you 1) mean by matched 2) what the output should look like and 3) which method you are "matching".
A skeleton of a data step merge that does this:
data matched notmatched; merge a (in=ina) b (in=inb) ; by byvariables; if ina and inb then output matched; else output notmatched; run;
The in variables are temporary variables not written to output and indicate which data sets are contributing to the current observation.
However without details of actual data output needs given some input sets a merge may not be appropriate, or what to do with like named variables other than those used on the BY statement are important to know.
The matching is done on the values of variables on the BY statement and the data sets would need to all be sorted by the by variables prior to the merge.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.