10-04-2016 12:50 PM
It is possible to match Datasets using differents variables with merge?
If I have 3 DataSets (DS):
DS1 and DS2 can be matched by var1
DS2 and DS3 only by Var2 (Var2 has differente data than Var1)
I know that is possible in diferent data steps or using proc SQL, but I want to know if is possible with merge in one step or exists other method using SAS code.
10-04-2016 01:38 PM
MERGE won't do that at all. You can force a DATA step to do what you are asking, but it is not necessarily simple. And the complexities multiply if you have a possibility of mismatches or a possiblity of a many-to-one (or worse yet, many-to-many) match. Here are a couple of ideas.
In terms of speed and simplicity, I would probably go with the hash table. But nothing is simple. For example, what should happen if the hash table contains a data value that does not have a match either of the other two data sets?
10-05-2016 01:47 AM
Since you can only have one BY statement in the data step, this is not possible.
Use SQL for doing that in one step. But be aware that joining multiple large tables in SQL will often perform horribly compared to a sequence of SORT and MERGE steps.