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.
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?
Proc SQL is the exact tool for that task. Be aware however that for many-to-many merges it is not equivalent to the data step.
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.