Hi,
I want to have two different conditions to merge two datasets.
one with the same ticker and particular period.
or second one with the same id and particular period.
Would below codes work?
sql;
create table abc as
select I.*,N.MEDEST, N.FPEDATS
from rs_gvkey_1 as I left join CFF_1 as N
on I.ticker=N.OFTIC and I.disdate <= N.FPEDATS < intnx('month',I.disdate,+3,'same')
or I.cusip=N.cusip and I.disdate <= N.FPEDATS < intnx('month',I.disdate,+3,'same');
run;
It should work. I would prefer to write it as:
proc sql;
create table abc as
select I.*, N.MEDEST, N.FPEDATS
from rs_gvkey_1 as I left join CFF_1 as N
on (I.disdate <= N.FPEDATS < intnx('month', I.disdate, +3, 'same')) and
(I.ticker=N.OFTIC or I.cusip=N.cusip);
quit;
(untested)
PG
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.