BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Songchan
Calcite | Level 5

Hello there,

 

I want to combine two data sets temp03 and temp04 using proc sql select, but it turns out that data set temp04 in my table link is empty.

what's the possible reason of that problem?

 

 

proc sql;
create table link as
select distinct temp03.*,temp04.*
from temp03 as a
left join temp04(where=(linktype in ('LC' 'LU') and
linkprim in ('P' 'C' 'J'))) as b

on a.permno=b.lpermno and b.linkdt<a.date;
quit;

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

The condition b.linkdt<a.date might be a comparison between a datetime value (b.linkdt) and a date value (a.date). try changing to

datepart(b.linkdt) < a.date

PG

View solution in original post

8 REPLIES 8
Reeza
Super User

Remove your WHERE conditions and add them one at a time to see if one is returning an empty table.

 


@Songchan wrote:

Hello there,

 

I want to combine two data sets temp03 and temp04 using proc sql select, but it turns out that data set temp04 in my table link is empty.

what's the possible reason of that problem?

 

 

proc sql;
create table link as
select distinct temp03.*,temp04.*
from temp03 as a
left join temp04(where=(linktype in ('LC' 'LU') and
linkprim in ('P' 'C' 'J'))) as b

on a.permno=b.lpermno and b.linkdt<a.date;
quit;


 

Songchan
Calcite | Level 5

No, still doesn't work

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

I have not seen the data but would this work:

proc sql;
create table link as
select distinct a.*, b.*
from temp03 as a
left join temp04(where=(upcase(linktype) in ('LC' 'LU') and
upcase(linkprim) in ('P' 'C' 'J'))) as b

on a.permno=b.lpermno and b.linkdt<a.date;
quit;
Songchan
Calcite | Level 5

Thanks for replying,

but it still doesn't work

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

is it posable that b.linkdt <= a.date ?

 

Songchan
Calcite | Level 5
No, still empty for data set temp04
PGStats
Opal | Level 21

The condition b.linkdt<a.date might be a comparison between a datetime value (b.linkdt) and a date value (a.date). try changing to

datepart(b.linkdt) < a.date

PG
Songchan
Calcite | Level 5
Thank you PG! it works!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 8 replies
  • 1675 views
  • 0 likes
  • 4 in conversation