The choice between Merge in a datastep and an SQL Join would usually come up when you have many to one or many to many questions. If there is only one of each then either should produce the same result.
I would probably use Proc SQL as that wouldn't require sorting the data first:
proc sql;
create table want as
select a.*, b.expenses
from revenuedataset as a left join expensedataset as b
on a.corp_stat=b.corp_stat and a.naics=b.naics and a.prov_code=b.prov_code;
quit;
The choice between Merge in a datastep and an SQL Join would usually come up when you have many to one or many to many questions. If there is only one of each then either should produce the same result.
I would probably use Proc SQL as that wouldn't require sorting the data first:
proc sql;
create table want as
select a.*, b.expenses
from revenuedataset as a left join expensedataset as b
on a.corp_stat=b.corp_stat and a.naics=b.naics and a.prov_code=b.prov_code;
quit;
Thanks for the info....Jack
If you are new enough to SAS to ask, I reckon a data step is better. It gives much more information about how data was processed, and its syntax is less prone to errors.
SQL has a more natural syntax, but this apparent familiarity is misleading and it is very easy to *not* get the expected result.
Thanks for the advice....Jack
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.