BookmarkSubscribeRSS Feed
fafrin420
Fluorite | Level 6
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. 

:Dataset aDataset abb

1 REPLY 1
PGStats
Opal | Level 21

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;
PG

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 12011 views
  • 0 likes
  • 2 in conversation