BookmarkSubscribeRSS Feed
JPARK
Calcite | Level 5

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;

1 REPLY 1
PGStats
Opal | Level 21

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

PG

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 476 views
  • 4 likes
  • 2 in conversation