proc sql;
create table master_table as select a.*, b.*
from dataseta a left join datasetb b
on a.permno = b.permno
where intnx('month',a.date,12,'E')>= b.date
group by a.permno, a.date;
quit;
Hi,
My dataset b contains r_size, size_min, size_max, permno date. This dataset has rows of observation for the month of June. The dataset a dates that ranges for all month. I want to merge the dataset b with dataset a matching permno of both dataset and giving the same row from dataset b to every month of year in dataset a that follows the month of June in dataset b .
For example, as an end output, for permno 92719, r_size should be 0, size_min should be 0 etc. for 31DEC1990 in the merged dataset.
:
I guess you may need to do:
proc sql;
create table master_table as
select
a.*,
b.r_size,
b.size_min,
b.size_max,
b.date as date_b
from
dataseta a left join
datasetb b
on a.permno=b.permno and
year(a.date) = year(b.date);
quit;
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.