Macro:
%macro join_tables(in_dsn1 = , in_dsn2=, out_dsn=);
CREATE TABLE X_&out_dsn AS
SELECT
T1.ACCT_KEY,
T2.ACCT_KEY,
T1.REPORTED_MONTH,
T2.REPORTED_MONTH,
T1.EVDESC,
T2.EVDESC,
COUNT(*)FROM DB1.&in.dsn2 AS T1
INNER JOIN DB2.&in_dsn2 AS T2
ON T1.ACCT_KEY = T2.ACCT_KEY
AND T1.EVDESC = T2.EVDESC
GROUP BY 1,2,3,4,5,6;
%mend join_tables;
%join_tables(in_dsn1 =Table_11801 , in_dsn2= Table_11711, out_dsn=out_name);
The next step is building a table that has the dates you need to run, I'll let you attempt that first. Then JOIN_TABLES call can be called from CALL EXECUTE.
If you can't get it working, post back with what you've tried and what isn't working.
... View more